diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2011-07-08 16:49:07 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2011-07-08 16:49:07 (GMT) |
commit | 7128f95bd27b34c82299d8572d4172bf0c8a13a3 (patch) | |
tree | 5d73969ecb7d13388554dacfb7a298c3b5fa3a89 /Modules | |
parent | 4468e55d4bd2a9ac4c6aeaffeb99653b7737ebd6 (diff) | |
parent | b9ac25d1c394714f0565845b274e7eebb402f1e7 (diff) | |
download | cpython-7128f95bd27b34c82299d8572d4172bf0c8a13a3.zip cpython-7128f95bd27b34c82299d8572d4172bf0c8a13a3.tar.gz cpython-7128f95bd27b34c82299d8572d4172bf0c8a13a3.tar.bz2 |
Issue #12440: When testing whether some bits in SSLContext.options can be
reset, check the version of the OpenSSL headers Python was compiled against,
rather than the runtime version of the OpenSSL library.
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_ssl.c | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/Modules/_ssl.c b/Modules/_ssl.c index 3f631e3..d2d2480 100644 --- a/Modules/_ssl.c +++ b/Modules/_ssl.c @@ -2101,6 +2101,24 @@ static struct PyModuleDef _sslmodule = { NULL }; + +static void +parse_openssl_version(unsigned long libver, + unsigned int *major, unsigned int *minor, + unsigned int *fix, unsigned int *patch, + unsigned int *status) +{ + *status = libver & 0xF; + libver >>= 4; + *patch = libver & 0xFF; + libver >>= 8; + *fix = libver & 0xFF; + libver >>= 8; + *minor = libver & 0xFF; + libver >>= 8; + *major = libver & 0xFF; +} + PyMODINIT_FUNC PyInit__ssl(void) { @@ -2213,15 +2231,7 @@ PyInit__ssl(void) return NULL; if (PyModule_AddObject(m, "OPENSSL_VERSION_NUMBER", r)) return NULL; - status = libver & 0xF; - libver >>= 4; - patch = libver & 0xFF; - libver >>= 8; - fix = libver & 0xFF; - libver >>= 8; - minor = libver & 0xFF; - libver >>= 8; - major = libver & 0xFF; + parse_openssl_version(libver, &major, &minor, &fix, &patch, &status); r = Py_BuildValue("IIIII", major, minor, fix, patch, status); if (r == NULL || PyModule_AddObject(m, "OPENSSL_VERSION_INFO", r)) return NULL; @@ -2229,5 +2239,11 @@ PyInit__ssl(void) if (r == NULL || PyModule_AddObject(m, "OPENSSL_VERSION", r)) return NULL; + libver = OPENSSL_VERSION_NUMBER; + parse_openssl_version(libver, &major, &minor, &fix, &patch, &status); + r = Py_BuildValue("IIIII", major, minor, fix, patch, status); + if (r == NULL || PyModule_AddObject(m, "_OPENSSL_API_VERSION", r)) + return NULL; + return m; } |