Fix SSL initialization for OpenSSL >= 1.1.

Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
(cherry picked from commit 43609c8a21)
r14.0.x
Slávek Banko 6 years ago
parent 6fe60cb91f
commit 5649783834
No known key found for this signature in database
GPG Key ID: 608F5293A04BE668

@ -37,6 +37,13 @@
#define GET_CRYPTOLIB_SYMBOL(a) ((_cryptoLib->hasSymbol(a)) ? _cryptoLib->symbol(a) : NULL) #define GET_CRYPTOLIB_SYMBOL(a) ((_cryptoLib->hasSymbol(a)) ? _cryptoLib->symbol(a) : NULL)
#define GET_SSLLIB_SYMBOL(a) ((_sslLib->hasSymbol(a)) ? _sslLib->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" { extern "C" {
#ifdef KSSL_HAVE_SSL #ifdef KSSL_HAVE_SSL
static int (*K_SSL_connect) (SSL *) = 0L; static int (*K_SSL_connect) (SSL *) = 0L;
@ -675,6 +682,20 @@ TDEConfig *cfg;
// Initialize the library (once only!) // Initialize the library (once only!)
void *x; void *x;
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"); x = GET_SSLLIB_SYMBOL("SSL_library_init");
if (_cryptoLib) { if (_cryptoLib) {
if (x) ((int (*)())x)(); if (x) ((int (*)())x)();
@ -707,6 +728,7 @@ TDEConfig *cfg;
if (x) ((void (*)())x)(); if (x) ((void (*)())x)();
} }
} }
}
} }

Loading…
Cancel
Save