IN: io.sockets.secure.tests USING: accessors kernel namespaces io io.sockets io.sockets.secure io.encodings.ascii io.streams.duplex classes words destructors threads tools.test concurrency.promises byte-arrays ; \ must-infer { 1 0 } [ [ ] with-secure-context ] must-infer-as [ ] [ "port" set ] unit-test [ ] [ [ "resource:extra/openssl/test/server.pem" >>key-file "resource:extra/openssl/test/root.pem" >>ca-file "resource:extra/openssl/test/dh1024.pem" >>dh-file "password" >byte-array >>password [ "127.0.0.1" 0 ascii [ dup addr>> addrspec>> port>> "port" get fulfill accept [ class word-name write ] curry with-stream ] with-disposal ] with-secure-context ] "SSL server test" spawn drop ] unit-test [ "secure" ] [ [ "127.0.0.1" "port" get ?promise ascii drop contents ] with-secure-context ] unit-test ! Now, see what happens if the server closes the connection prematurely [ ] [ "port" set ] unit-test [ ] [ [ "resource:extra/openssl/test/server.pem" >>key-file "resource:extra/openssl/test/root.pem" >>ca-file "resource:extra/openssl/test/dh1024.pem" >>dh-file "password" >byte-array >>password [ "127.0.0.1" 0 ascii [ dup addr>> addrspec>> port>> "port" get fulfill accept drop [ dup in>> stream>> handle>> f >>connected drop "hello" over stream-write dup stream-flush ] with-disposal ] with-disposal ] with-secure-context ] "SSL server test" spawn drop ] unit-test [ [ "127.0.0.1" "port" get ?promise ascii drop contents ] with-secure-context ] [ premature-close = ] must-fail-with ! Now, try validating the certificate. This should fail because its ! actually an invalid certificate [ ] [ "port" set ] unit-test [ ] [ [ "resource:extra/openssl/test/server.pem" >>key-file "resource:extra/openssl/test/root.pem" >>ca-file "resource:extra/openssl/test/dh1024.pem" >>dh-file "password" >byte-array >>password [ "127.0.0.1" 0 ascii [ dup addr>> addrspec>> port>> "port" get fulfill accept drop dispose ] with-disposal ] with-secure-context ] "SSL server test" spawn drop ] unit-test [ [ "localhost" "port" get ?promise ascii drop dispose ] with-secure-context ] [ certificate-verify-error? ] must-fail-with