summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2011-05-09 22:38:00 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2011-05-09 22:38:00 (GMT)
commitee18b6f2fda4afcdd1a22adb5b0637019510907b (patch)
tree0c2edfbffca2241eb3b42afb41adf0fc4002f886 /Modules
parent4755ab010f18863e305bbd17bbc16b7f39aed360 (diff)
downloadcpython-ee18b6f2fda4afcdd1a22adb5b0637019510907b.zip
cpython-ee18b6f2fda4afcdd1a22adb5b0637019510907b.tar.gz
cpython-ee18b6f2fda4afcdd1a22adb5b0637019510907b.tar.bz2
Issue #12012: ssl.PROTOCOL_SSLv2 becomes optional
OpenSSL is now compiled with OPENSSL_NO_SSL2 defined (without the SSLv2 protocol) on Debian: fix the ssl module on Debian Testing and Debian Sid. Optimize also ssl.get_protocol_name(): speed does matter!
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_ssl.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/Modules/_ssl.c b/Modules/_ssl.c
index 73a76bb..8ebdc9b 100644
--- a/Modules/_ssl.c
+++ b/Modules/_ssl.c
@@ -63,8 +63,10 @@ enum py_ssl_cert_requirements {
};
enum py_ssl_version {
+#ifndef OPENSSL_NO_SSL2
PY_SSL_VERSION_SSL2,
- PY_SSL_VERSION_SSL3,
+#endif
+ PY_SSL_VERSION_SSL3=1,
PY_SSL_VERSION_SSL23,
PY_SSL_VERSION_TLS1
};
@@ -306,8 +308,10 @@ newPySSLObject(PySocketSockObject *Sock, char *key_file, char *cert_file,
self->ctx = SSL_CTX_new(TLSv1_method()); /* Set up context */
else if (proto_version == PY_SSL_VERSION_SSL3)
self->ctx = SSL_CTX_new(SSLv3_method()); /* Set up context */
+#ifndef OPENSSL_NO_SSL2
else if (proto_version == PY_SSL_VERSION_SSL2)
self->ctx = SSL_CTX_new(SSLv2_method()); /* Set up context */
+#endif
else if (proto_version == PY_SSL_VERSION_SSL23)
self->ctx = SSL_CTX_new(SSLv23_method()); /* Set up context */
PySSL_END_ALLOW_THREADS
@@ -1787,8 +1791,10 @@ PyInit__ssl(void)
PY_SSL_CERT_REQUIRED);
/* protocol versions */
+#ifndef OPENSSL_NO_SSL2
PyModule_AddIntConstant(m, "PROTOCOL_SSLv2",
PY_SSL_VERSION_SSL2);
+#endif
PyModule_AddIntConstant(m, "PROTOCOL_SSLv3",
PY_SSL_VERSION_SSL3);
PyModule_AddIntConstant(m, "PROTOCOL_SSLv23",