Skip to content

Commit 387c744

Browse files
authored
[3.8] bpo-40515: Require OPENSSL_THREADS (GH-19953) (GH-20119)
1 parent 5a06cf0 commit 387c744

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
The :mod:`ssl` and :mod:`hashlib` modules now actively check that OpenSSL is
2+
build with thread support. Python 3.7.0 made thread support mandatory and no
3+
longer works safely with a no-thread builds.

Modules/_hashopenssl.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@
2626
#include <openssl/objects.h>
2727
#include "openssl/err.h"
2828

29+
#ifndef OPENSSL_THREADS
30+
# error "OPENSSL_THREADS is not defined, Python requires thread-safe OpenSSL"
31+
#endif
32+
2933
#if (OPENSSL_VERSION_NUMBER < 0x10100000L) || defined(LIBRESSL_VERSION_NUMBER)
3034
/* OpenSSL < 1.1.0 */
3135
#define EVP_MD_CTX_new EVP_MD_CTX_create

Modules/_ssl.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ static PySocketModule_APIObject PySocketModule;
7575
# endif
7676
#endif
7777

78+
#ifndef OPENSSL_THREADS
79+
# error "OPENSSL_THREADS is not defined, Python requires thread-safe OpenSSL"
80+
#endif
81+
7882
/* SSL error object */
7983
static PyObject *PySSLErrorObject;
8084
static PyObject *PySSLCertVerificationErrorObject;
@@ -6008,7 +6012,7 @@ PyInit__ssl(void)
60086012
if (!_setup_ssl_threads()) {
60096013
return NULL;
60106014
}
6011-
#elif OPENSSL_VERSION_1_1 && defined(OPENSSL_THREADS)
6015+
#elif OPENSSL_VERSION_1_1
60126016
/* OpenSSL 1.1.0 builtin thread support is enabled */
60136017
_ssl_locks_count++;
60146018
#endif

0 commit comments

Comments
 (0)