diff options
author | Slávek Banko <slavek.banko@axis.cz> | 2019-02-21 15:21:00 +0100 |
---|---|---|
committer | Slávek Banko <slavek.banko@axis.cz> | 2019-02-21 17:33:56 +0100 |
commit | 4e6b9128f722d7a45188b2c2fc3ecdb887de6cc9 (patch) | |
tree | 23732ec901ab4dbdd07a2d164d77eeb24567f4d4 | |
parent | 81ae75ca14770c0004e99759c42f579fd29a34b4 (diff) | |
download | tdelibs-4e6b9128f722d7a45188b2c2fc3ecdb887de6cc9.tar.gz tdelibs-4e6b9128f722d7a45188b2c2fc3ecdb887de6cc9.zip |
Fix SSL initialization for OpenSSL >= 1.1.
Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
(cherry picked from commit 43609c8a21144b56a53d53757639fc6c6298c10d)
-rw-r--r-- | kio/kssl/kopenssl.cc | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/kio/kssl/kopenssl.cc b/kio/kssl/kopenssl.cc index 924f1b960..cd880540f 100644 --- a/kio/kssl/kopenssl.cc +++ b/kio/kssl/kopenssl.cc @@ -37,6 +37,13 @@ #define GET_CRYPTOLIB_SYMBOL(a) ((_cryptoLib->hasSymbol(a)) ? _cryptoLib->symbol(a) : NULL) #define GET_SSLLIB_SYMBOL(a) ((_sslLib->hasSymbol(a)) ? _sslLib->symbol(a) : NULL) +// taken from OpenSSL 1.1 header, used to call OPENSSL_init_crypto +#if !defined(OPENSSL_INIT_ADD_ALL_CIPHERS) +# define OPENSSL_INIT_ADD_ALL_CIPHERS 0x00000004L +# define OPENSSL_INIT_ADD_ALL_DIGESTS 0x00000008L +# define OPENSSL_INIT_LOAD_CONFIG 0x00000040L +#endif + extern "C" { #ifdef KSSL_HAVE_SSL static int (*K_SSL_connect) (SSL *) = 0L; @@ -675,8 +682,22 @@ KConfig *cfg; // Initialize the library (once only!) void *x; - x = GET_SSLLIB_SYMBOL("SSL_library_init"); - if (_cryptoLib) { + x = GET_SSLLIB_SYMBOL("OPENSSL_init_ssl"); + if (x) { + // OpenSSL >= 1.1 + if (_cryptoLib) { + ((int (*)(unsigned long, void*))x)(0, NULL); + x = GET_CRYPTOLIB_SYMBOL("OPENSSL_init_crypto"); + if (x) ((int (*)(unsigned long, void*))x)(OPENSSL_INIT_ADD_ALL_CIPHERS + | OPENSSL_INIT_ADD_ALL_DIGESTS + | OPENSSL_INIT_LOAD_CONFIG, + NULL); + } + } + else { + // OpenSSL < 1.1 + x = GET_SSLLIB_SYMBOL("SSL_library_init"); + if (_cryptoLib) { if (x) ((int (*)())x)(); x = GET_CRYPTOLIB_SYMBOL("OpenSSL_add_all_algorithms"); if (!x) @@ -705,6 +726,7 @@ KConfig *cfg; if (!x) x = GET_CRYPTOLIB_SYMBOL("OPENSSL_add_all_digests"); if (x) ((void (*)())x)(); + } } } |