ERROR: library-missing library ;
-: find-first-function ( names library -- function/f )
+: find-first-function ( names library -- alien/f name )
libraries get ?at [
- dll>> '[ _ dlsym ] map-find nip
+ dll>> '[ _ dlsym ] map-find
] [
library-missing
- ] if ;
+ ] if ; inline
! Try to find the library from a list, but if it's not found,
! try to open a library that is the first name in that list anyway
=
] if ;
-: get-peer-certificate-function ( -- word/f )
- { "SSL_get1_peer_certificate" "SSL_get_peer_certificate" } "libssl" find-first-function ;
-
: check-subject-name ( host ssl-handle -- )
- get-peer-certificate-function execute( ssl -- x509 ) [
+ get-ssl-peer-certificate [
[ alternative-dns-names ]
[ subject-name ] bi suffix members
2dup [ subject-names-match? ] with any?
! Portions copyright (C) 2008 Slava Pestov
! See http://factorcode.org/license.txt for BSD license.
USING: alien alien.c-types alien.destructors alien.libraries
-alien.parser alien.syntax classes.struct combinators kernel
-literals namespaces openssl.libcrypto system ;
-SLOT: alpn-supported-protocols
+alien.libraries.finder alien.parser alien.syntax classes.struct
+combinators kernel literals namespaces openssl.libcrypto system
+words ;
IN: openssl.libssl
<< "libssl" {
FUNCTION: X509 *SSL_get0_peer_certificate ( SSL *ssl )
FUNCTION: X509 *SSL_get1_peer_certificate ( SSL *ssl )
+: get-ssl-peer-certificate ( ssl -- x509 )
+ { "SSL_get1_peer_certificate" "SSL_get_peer_certificate" } "libssl" find-first-function nip
+ "openssl.libssl" lookup-word execute( ssl -- x509 ) ; inline
+
FUNCTION: int SSL_set_cipher_list ( SSL* ssl, c-string str )
FUNCTION: int SSL_use_RSAPrivateKey_file ( SSL* ssl, c-string str )
FUNCTION: int SSL_use_certificate_file ( SSL* ssl, c-string str, int type )