diff options
author | Christian Heimes <christian@python.org> | 2020-05-15 20:36:51 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-15 20:36:51 (GMT) |
commit | 387c7441f589cc45ea86f1fa257af616c39d9a4b (patch) | |
tree | 6416647e8e905f2ea041755b883569a3b1eaddf6 | |
parent | 5a06cf01ecb6a048fb47c086adc1336f54fe8789 (diff) | |
download | cpython-387c7441f589cc45ea86f1fa257af616c39d9a4b.zip cpython-387c7441f589cc45ea86f1fa257af616c39d9a4b.tar.gz cpython-387c7441f589cc45ea86f1fa257af616c39d9a4b.tar.bz2 |
[3.8] bpo-40515: Require OPENSSL_THREADS (GH-19953) (GH-20119)
-rw-r--r-- | Misc/NEWS.d/next/Library/2020-05-06-13-51-19.bpo-40515.TUCvYB.rst | 3 | ||||
-rw-r--r-- | Modules/_hashopenssl.c | 4 | ||||
-rw-r--r-- | Modules/_ssl.c | 6 |
3 files changed, 12 insertions, 1 deletions
diff --git a/Misc/NEWS.d/next/Library/2020-05-06-13-51-19.bpo-40515.TUCvYB.rst b/Misc/NEWS.d/next/Library/2020-05-06-13-51-19.bpo-40515.TUCvYB.rst new file mode 100644 index 0000000..af77a57 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2020-05-06-13-51-19.bpo-40515.TUCvYB.rst @@ -0,0 +1,3 @@ +The :mod:`ssl` and :mod:`hashlib` modules now actively check that OpenSSL is +build with thread support. Python 3.7.0 made thread support mandatory and no +longer works safely with a no-thread builds. diff --git a/Modules/_hashopenssl.c b/Modules/_hashopenssl.c index 3e5f9c3..edadbcb 100644 --- a/Modules/_hashopenssl.c +++ b/Modules/_hashopenssl.c @@ -26,6 +26,10 @@ #include <openssl/objects.h> #include "openssl/err.h" +#ifndef OPENSSL_THREADS +# error "OPENSSL_THREADS is not defined, Python requires thread-safe OpenSSL" +#endif + #if (OPENSSL_VERSION_NUMBER < 0x10100000L) || defined(LIBRESSL_VERSION_NUMBER) /* OpenSSL < 1.1.0 */ #define EVP_MD_CTX_new EVP_MD_CTX_create diff --git a/Modules/_ssl.c b/Modules/_ssl.c index 43b236c..1da65ea 100644 --- a/Modules/_ssl.c +++ b/Modules/_ssl.c @@ -75,6 +75,10 @@ static PySocketModule_APIObject PySocketModule; # endif #endif +#ifndef OPENSSL_THREADS +# error "OPENSSL_THREADS is not defined, Python requires thread-safe OpenSSL" +#endif + /* SSL error object */ static PyObject *PySSLErrorObject; static PyObject *PySSLCertVerificationErrorObject; @@ -6008,7 +6012,7 @@ PyInit__ssl(void) if (!_setup_ssl_threads()) { return NULL; } -#elif OPENSSL_VERSION_1_1 && defined(OPENSSL_THREADS) +#elif OPENSSL_VERSION_1_1 /* OpenSSL 1.1.0 builtin thread support is enabled */ _ssl_locks_count++; #endif |