Skip to content

Commit efc9065

Browse files
authored
[3.7] bpo-40515: Require OPENSSL_THREADS (GH-19953) (GH-20120)
1 parent 5e6b491 commit efc9065

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
@@ -32,6 +32,10 @@ module _hashlib
3232
[clinic start generated code]*/
3333
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=c2b4ff081bac4be1]*/
3434

35+
#ifndef OPENSSL_THREADS
36+
# error "OPENSSL_THREADS is not defined, Python requires thread-safe OpenSSL"
37+
#endif
38+
3539
#define MUNCH_SIZE INT_MAX
3640

3741
#ifndef HASH_OBJ_CONSTRUCTOR

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;
@@ -5875,7 +5879,7 @@ PyInit__ssl(void)
58755879
if (!_setup_ssl_threads()) {
58765880
return NULL;
58775881
}
5878-
#elif OPENSSL_VERSION_1_1 && defined(OPENSSL_THREADS)
5882+
#elif OPENSSL_VERSION_1_1
58795883
/* OpenSSL 1.1.0 builtin thread support is enabled */
58805884
_ssl_locks_count++;
58815885
#endif

0 commit comments

Comments
 (0)