]> granicus.if.org Git - python/commitdiff
Issue #20207: Always disable SSLv2 except when PROTOCOL_SSLv2 is explicitly asked...
authorAntoine Pitrou <solipsis@pitrou.net>
Thu, 9 Jan 2014 18:52:12 +0000 (19:52 +0100)
committerAntoine Pitrou <solipsis@pitrou.net>
Thu, 9 Jan 2014 18:52:12 +0000 (19:52 +0100)
Lib/test/test_ssl.py
Misc/NEWS
Modules/_ssl.c

index c1c338449a4f6b80b0df5ac02566f5eb3627a063..426e26138271d6a4d2a8e3255b773c26ed6905e2 100644 (file)
@@ -1052,7 +1052,7 @@ else:
             try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv2, True)
             try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv2, True, ssl.CERT_OPTIONAL)
             try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv2, True, ssl.CERT_REQUIRED)
-            try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv23, True)
+            try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv23, False)
             try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv3, False)
             try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_TLSv1, False)
 
index 91278d9bcf8b4539df5c8b4596e63875dd4cb1a4..3d077041fb2413804f14f2425789ef1be9231e17 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -35,6 +35,9 @@ Core and Builtins
 Library
 -------
 
+- Issue #20207: Always disable SSLv2 except when PROTOCOL_SSLv2 is explicitly
+  asked for.
+
 - Issue #20072: Fixed multiple errors in tkinter with wantobjects is False.
 
 - Issue #1065986: pydoc can now handle unicode strings.
index ba645557996ca37bb486c0fd68ce80581ef4c888..752b033e75eb782eddfdc995ed017b58b43a88ee 100644 (file)
@@ -273,6 +273,7 @@ newPySSLObject(PySocketSockObject *Sock, char *key_file, char *cert_file,
     char *errstr = NULL;
     int ret;
     int verification_mode;
+    long options;
 
     self = PyObject_New(PySSLObject, &PySSL_Type); /* Create new object */
     if (self == NULL)
@@ -372,8 +373,10 @@ newPySSLObject(PySocketSockObject *Sock, char *key_file, char *cert_file,
     }
 
     /* ssl compatibility */
-    SSL_CTX_set_options(self->ctx,
-                        SSL_OP_ALL & ~SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS);
+    options = SSL_OP_ALL & ~SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS;
+    if (proto_version != PY_SSL_VERSION_SSL2)
+        options |= SSL_OP_NO_SSLv2;
+    SSL_CTX_set_options(self->ctx, options);
 
     verification_mode = SSL_VERIFY_NONE;
     if (certreq == PY_SSL_CERT_OPTIONAL)