io.sockets.secure.openssl: some style improvements.
parent
44a1d61bd4
commit
32b07016b0
|
@ -1,11 +1,11 @@
|
||||||
! Copyright (C) 2007, 2008, Slava Pestov, Elie CHAFTARI.
|
! Copyright (C) 2007, 2008, Slava Pestov, Elie CHAFTARI.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: accessors byte-arrays classes.struct kernel sequences namespaces math
|
USING: accessors alien alien.c-types alien.data alien.strings
|
||||||
math.order combinators init alien alien.c-types alien.data
|
assocs byte-arrays classes.struct combinators destructors
|
||||||
alien.strings libc continuations destructors summary splitting
|
io.backend io.encodings.8-bit.latin1 io.encodings.utf8
|
||||||
assocs random math.parser locals unicode.case openssl
|
io.pathnames io.sockets.secure kernel libc locals math
|
||||||
openssl.libcrypto openssl.libssl io.backend io.ports io.pathnames
|
math.order math.parser namespaces openssl openssl.libcrypto
|
||||||
io.encodings.8-bit.latin1 io.encodings.utf8 io.timeouts io.sockets.secure ;
|
openssl.libssl random sequences splitting unicode.case ;
|
||||||
IN: io.sockets.secure.openssl
|
IN: io.sockets.secure.openssl
|
||||||
|
|
||||||
GENERIC: ssl-method ( symbol -- method )
|
GENERIC: ssl-method ( symbol -- method )
|
||||||
|
@ -181,11 +181,12 @@ M: ssl-handle dispose*
|
||||||
: issuer-name ( certificate -- issuer )
|
: issuer-name ( certificate -- issuer )
|
||||||
X509_get_issuer_name x509name>string ;
|
X509_get_issuer_name x509name>string ;
|
||||||
|
|
||||||
: name-stack>seq ( name-stack -- seq )
|
: name-stack>sequence ( name-stack -- seq )
|
||||||
dup sk_num iota [ sk_value GENERAL_NAME_st memory>struct ] with map ;
|
dup sk_num iota [ sk_value GENERAL_NAME_st memory>struct ] with map ;
|
||||||
|
|
||||||
: alternative-dns-names ( certificate -- dns-names )
|
: alternative-dns-names ( certificate -- dns-names )
|
||||||
NID_subject_alt_name f f X509_get_ext_d2i [ name-stack>seq ] [ { } ] if*
|
NID_subject_alt_name f f X509_get_ext_d2i
|
||||||
|
[ name-stack>sequence ] [ f ] if*
|
||||||
[ type>> GEN_DNS = ] filter
|
[ type>> GEN_DNS = ] filter
|
||||||
[ d>> dNSName>> data>> utf8 alien>string ] map ;
|
[ d>> dNSName>> data>> utf8 alien>string ] map ;
|
||||||
|
|
||||||
|
@ -193,9 +194,10 @@ M: ssl-handle dispose*
|
||||||
[ >lower ] bi@ "*." ?head [ tail? ] [ = ] if ;
|
[ >lower ] bi@ "*." ?head [ tail? ] [ = ] if ;
|
||||||
|
|
||||||
: check-subject-name ( host ssl-handle -- )
|
: check-subject-name ( host ssl-handle -- )
|
||||||
SSL_get_peer_certificate [ alternative-dns-names ] [ subject-name ] bi
|
SSL_get_peer_certificate
|
||||||
suffix 2dup [ subject-names-match? ] with filter empty?
|
[ alternative-dns-names ] [ subject-name ] bi suffix
|
||||||
[ subject-name-verify-error ] [ 2drop ] if ;
|
2dup [ subject-names-match? ] with any?
|
||||||
|
[ 2drop ] [ subject-name-verify-error ] if ;
|
||||||
|
|
||||||
M: openssl check-certificate ( host ssl -- )
|
M: openssl check-certificate ( host ssl -- )
|
||||||
current-secure-context config>> verify>> [
|
current-secure-context config>> verify>> [
|
||||||
|
|
Loading…
Reference in New Issue