V{ } clone >>aliens
H{ } clone >>sessions ;
-M: openssl <secure-context> ( config -- context )
+M: openssl <secure-context>
maybe-init-ssl
[
dup method>> ssl-method SSL_CTX_new
{ { SSL_ERROR_ZERO_RETURN [ drop f ] } } check-ssl-error
] keep swap [ 2nip ] [ swap buffer+ f ] if* ;
-M: ssl-handle refill ( port handle -- event/f )
+M: ssl-handle refill
dup maybe-handshake [ buffer>> ] [ handle>> ] bi* do-ssl-read ;
! Output ports
2dup swap [ buffer@ ] [ buffer-length ] bi SSL_write
[ f check-ssl-error ] keep swap [ 2nip ] [ swap buffer-consume f ] if* ;
-M: ssl-handle drain ( port handle -- event/f )
+M: ssl-handle drain
dup maybe-handshake [ buffer>> ] [ handle>> ] bi* do-ssl-write ;
! Connect
[ 2drop ] [ subject-name-verify-error ] if
] [ certificate-missing-error ] if* ;
-M: openssl check-certificate ( host ssl -- )
+M: openssl check-certificate
current-secure-context config>> verify>> [
handle>>
[ nip check-verify-result ]
host>> swap handle>> check-certificate
] [ 2drop ] if ;
-M: openssl accept-secure-handshake ( -- )
+M: openssl accept-secure-handshake
input/output-ports
make-input/output-secure ;