summaryrefslogtreecommitdiffstats
path: root/tdeio
diff options
context:
space:
mode:
authorSlávek Banko <slavek.banko@axis.cz>2019-02-21 15:21:00 +0100
committerSlávek Banko <slavek.banko@axis.cz>2019-02-21 15:21:02 +0100
commit43609c8a21144b56a53d53757639fc6c6298c10d (patch)
treecfc4e98fbc4743bd81651a1b2d4ccd9aa82ce3f5 /tdeio
parenteea7fc0a83073892a72cac8fa7983a33bbed5059 (diff)
downloadtdelibs-43609c8a21144b56a53d53757639fc6c6298c10d.tar.gz
tdelibs-43609c8a21144b56a53d53757639fc6c6298c10d.zip
Fix SSL initialization for OpenSSL >= 1.1.
Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
Diffstat (limited to 'tdeio')
-rw-r--r--tdeio/kssl/kopenssl.cc26
1 files changed, 24 insertions, 2 deletions
diff --git a/tdeio/kssl/kopenssl.cc b/tdeio/kssl/kopenssl.cc
index 8b1aa20e0..ded836fde 100644
--- a/tdeio/kssl/kopenssl.cc
+++ b/tdeio/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 @@ TDEConfig *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 @@ TDEConfig *cfg;
if (!x)
x = GET_CRYPTOLIB_SYMBOL("OPENSSL_add_all_digests");
if (x) ((void (*)())x)();
+ }
}
}