SSL API fleshed out, doesn't work yet
parent
1260c1ba51
commit
dfb25c3350
|
@ -119,3 +119,5 @@ T{ dispose-dummy } "b" set
|
|||
[ t ] [ "b" get disposed?>> ] unit-test
|
||||
|
||||
[ ] [ [ return ] with-return ] unit-test
|
||||
|
||||
[ { } [ ] attempt-all ] [ attempt-all-error? ] must-fail-with
|
||||
|
|
|
@ -17,6 +17,8 @@ IN: http
|
|||
|
||||
: http-port 80 ; inline
|
||||
|
||||
: https-port 443 ; inline
|
||||
|
||||
: url-quotable? ( ch -- ? )
|
||||
#! In a URL, can this character be used without
|
||||
#! URL-encoding?
|
||||
|
|
|
@ -12,7 +12,7 @@ IN: io.unix.sockets.secure
|
|||
! todo: SSL_pending, rehandshake
|
||||
! do we call write twice, wth 0 bytes at the end?
|
||||
|
||||
M: ssl handle-fd file>> ;
|
||||
M: ssl-handle handle-fd file>> ;
|
||||
|
||||
: syscall-error ( port r -- )
|
||||
ERR_get_error dup zero? [
|
||||
|
@ -90,6 +90,6 @@ M: ssl ((client)) ( addrspec -- handle )
|
|||
} case ;
|
||||
|
||||
M: ssl-handle (wait-to-connect)
|
||||
handle>> handle>> ! ssl
|
||||
handle>> ! ssl
|
||||
SSL_connect
|
||||
check-connect-response ;
|
||||
|
|
|
@ -41,7 +41,7 @@ M: integer (wait-to-connect)
|
|||
M: connect-task do-io-task
|
||||
port>> dup handle>> (wait-to-connect) ;
|
||||
|
||||
M: integer wait-to-connect ( client-out fd -- )
|
||||
M: object wait-to-connect ( client-out fd -- )
|
||||
drop
|
||||
[ <connect-task> add-io-task ] with-port-continuation
|
||||
pending-error ;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: accessors byte-arrays kernel debugger sequences namespaces math
|
||||
math.order combinators init alien alien.c-types alien.strings libc
|
||||
continuations destructors
|
||||
continuations destructors debugger inspector
|
||||
locals unicode.case
|
||||
openssl.libcrypto openssl.libssl
|
||||
io.nonblocking io.files io.encodings.ascii io.sockets.secure ;
|
||||
|
@ -117,10 +117,19 @@ M: openssl-context dispose
|
|||
dup handle>> [ SSL_CTX_free ] when* f >>handle
|
||||
drop ;
|
||||
|
||||
TUPLE: ssl-handle file handle ;
|
||||
TUPLE: ssl-handle file handle disposed ;
|
||||
|
||||
ERROR: no-ssl-context ;
|
||||
|
||||
M: no-ssl-context summary
|
||||
drop "SSL operations must be wrapped in calls to with-ssl-context" ;
|
||||
|
||||
: current-ssl-context ( -- ctx )
|
||||
ssl-context get [ no-ssl-context ] unless* ;
|
||||
|
||||
: <ssl-handle> ( fd -- ssl )
|
||||
ssl-context get handle>> SSL_new dup ssl-error ssl-handle boa ;
|
||||
current-ssl-context handle>> SSL_new dup ssl-error
|
||||
f ssl-handle boa ;
|
||||
|
||||
: <ssl-socket> ( fd -- ssl )
|
||||
[ BIO_NOCLOSE BIO_new_socket dup ssl-error ] keep
|
||||
|
@ -130,7 +139,11 @@ TUPLE: ssl-handle file handle ;
|
|||
M: ssl-handle init-handle drop ;
|
||||
|
||||
M: ssl-handle close-handle
|
||||
[ file>> close-handle ] [ handle>> SSL_free ] bi ;
|
||||
dup disposed>> [ drop ] [
|
||||
[ t >>disposed drop ]
|
||||
[ file>> close-handle ]
|
||||
[ handle>> SSL_free ] tri
|
||||
] if ;
|
||||
|
||||
ERROR: certificate-verify-error result ;
|
||||
|
||||
|
|
Loading…
Reference in New Issue