Skip to content

Commit 9f45446

Browse files
cachedb_mongodb: complete fix in commit 298bf6b for openssl < 1.1.0
1 parent 298bf6b commit 9f45446

2 files changed

Lines changed: 72 additions & 4 deletions

File tree

modules/cachedb_mongodb/ssl_tweaks.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ SSL_CTX *SSL_CTX_new(const SSL_METHOD *method)
5252

5353
return real_SSL_CTX_new(method);
5454
}
55-
};
55+
}
5656

5757
void SSL_CTX_free(SSL_CTX *ctx)
5858
{
@@ -76,4 +76,4 @@ void SSL_CTX_free(SSL_CTX *ctx)
7676

7777
real_SSL_CTX_free(ctx);
7878
}
79-
};
79+
}

ssl_init_tweaks.h

Lines changed: 70 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "sr_module.h"
2626

2727
#if OPENSSL_VERSION_NUMBER >= 0x10100000L
28+
2829
int OPENSSL_init_ssl(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings)
2930
{
3031
int (*real_OPENSSL_init_ssl)(uint64_t, const OPENSSL_INIT_SETTINGS *);
@@ -42,7 +43,7 @@ int OPENSSL_init_ssl(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings)
4243

4344
return real_OPENSSL_init_ssl(opts, settings);
4445
}
45-
};
46+
}
4647

4748
int OPENSSL_init_crypto(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings)
4849
{
@@ -61,7 +62,7 @@ int OPENSSL_init_crypto(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings)
6162

6263
return real_OPENSSL_init_crypto(opts, settings);
6364
}
64-
};
65+
}
6566

6667
int ERR_load_BIO_strings(void)
6768
{
@@ -81,7 +82,9 @@ int ERR_load_BIO_strings(void)
8182
return real_ERR_load_BIO_strings();
8283
}
8384
}
85+
8486
#else
87+
8588
int SSL_library_init(void)
8689
{
8790
int (*real_SSL_library_init)(void);
@@ -119,4 +122,69 @@ void ERR_load_BIO_strings(void)
119122
real_ERR_load_BIO_strings();
120123
}
121124
}
125+
126+
void CRYPTO_set_locking_callback(void (*func)(int mode, int type,
127+
const char *file, int line))
128+
{
129+
int (*real_CRYPTO_set_locking_callback)(void (*)(int, int,
130+
const char *, int));
131+
static int have_tls_mgm = -1;
132+
133+
if (have_tls_mgm == -1)
134+
have_tls_mgm = module_loaded("tls_mgm");
135+
136+
if (have_tls_mgm) {
137+
return;
138+
} else {
139+
real_CRYPTO_set_locking_callback = dlsym(RTLD_NEXT,
140+
"CRYPTO_set_locking_callback");
141+
if (!real_CRYPTO_set_locking_callback)
142+
return;
143+
144+
real_CRYPTO_set_locking_callback(func);
145+
}
146+
}
147+
148+
#if OPENSSL_VERSION_NUMBER < 0x10000000L
149+
void CRYPTO_set_id_callback(unsigned long (*func) (void))
150+
{
151+
int (*real_CRYPTO_set_id_callback)(unsigned long (*)(void));
152+
static int have_tls_mgm = -1;
153+
154+
if (have_tls_mgm == -1)
155+
have_tls_mgm = module_loaded("tls_mgm");
156+
157+
if (have_tls_mgm) {
158+
return;
159+
} else {
160+
real_CRYPTO_set_id_callback = dlsym(RTLD_NEXT, "CRYPTO_set_id_callback");
161+
if (!real_CRYPTO_set_id_callback)
162+
return;
163+
164+
real_CRYPTO_set_id_callback(func);
165+
}
166+
}
167+
168+
#else /* between 1.0.0 and 1.1.0 */
169+
int CRYPTO_THREADID_set_callback(void (*threadid_func) (CRYPTO_THREADID *))
170+
{
171+
int (*real_CRYPTO_THREADID_set_callback)(void (*)(CRYPTO_THREADID *));
172+
static int have_tls_mgm = -1;
173+
174+
if (have_tls_mgm == -1)
175+
have_tls_mgm = module_loaded("tls_mgm");
176+
177+
if (have_tls_mgm) {
178+
return 0;
179+
} else {
180+
real_CRYPTO_THREADID_set_callback = dlsym(RTLD_NEXT,
181+
"CRYPTO_THREADID_set_callback");
182+
if (!real_CRYPTO_THREADID_set_callback)
183+
return 0;
184+
185+
return real_CRYPTO_THREADID_set_callback(threadid_func);
186+
}
187+
}
188+
#endif
189+
122190
#endif

0 commit comments

Comments
 (0)