Skip to content

Commit

Permalink
Acknowledge auto-init for libssl1 (orthecreedence#154)
Browse files Browse the repository at this point in the history
The function SSL_library_init is not available anymore in
libssl 1.0 and onwards.  The library uses another mechanism to
initialise itself.

It does not seem that there is an easy way to determine the version of
libssl we have loaded, we therefore rely on the presence of a
SSL_library_init foreign symbol to determine wether that function must
be called or not.

While libssl documentation claims the function SSL_load_error_strings
should be present in libssl 1.0 and onwards, it is not, at least on
Debian Stretch.  We use the same strategy as for SSL_library_init to
avoid a spurious call.

Reference: https://www.openssl.org/docs/man1.1.0/ssl/OPENSSL_init_ssl.html
  • Loading branch information
foretspaisibles committed Mar 30, 2018
1 parent 4e9292b commit c907906
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/ssl/tcp.lisp
Expand Up @@ -29,9 +29,12 @@

(defun ensure-init (&key from-load)
(unless *ssl-init*
(cffi:foreign-funcall ("SSL_library_init") :void)
(cffi:foreign-funcall ("SSL_load_error_strings") :void)
(cffi:foreign-funcall ("ERR_load_BIO_strings") :void)
(if (cffi:foreign-symbol-pointer "SSL_library_init" )
(cffi:foreign-funcall "SSL_library_init" :void)
(cffi:foreign-funcall "OPENSSL_init_ssl" :int 0 :int 0))
(when (cffi:foreign-symbol-pointer "SSL_load_error_strings")
(cffi:foreign-funcall "SSL_load_error_strings" :void))
(cffi:foreign-funcall "ERR_load_BIO_strings" :void)
(unless from-load
(setf *ssl-init* t)))))

Expand Down

0 comments on commit c907906

Please sign in to comment.