summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2010-04-21 19:46:23 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2010-04-21 19:46:23 (GMT)
commitfec12fff0f49275e0f7e2d52a689a709db41c0c1 (patch)
treef97d82923abc5ab82fae1a12a9608b786fe82243
parente7ed1d7f6808fc325154bd5e07de30e2a6a5b1bf (diff)
downloadcpython-fec12fff0f49275e0f7e2d52a689a709db41c0c1.zip
cpython-fec12fff0f49275e0f7e2d52a689a709db41c0c1.tar.gz
cpython-fec12fff0f49275e0f7e2d52a689a709db41c0c1.tar.bz2
Merged revisions 80314-80315 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r80314 | antoine.pitrou | 2010-04-21 21:28:03 +0200 (mer., 21 avril 2010) | 5 lines Issue #8484: Load all ciphers and digest algorithms when initializing the _ssl extension, such that verification of some SSL certificates doesn't fail because of an "unknown algorithm". ........ r80315 | antoine.pitrou | 2010-04-21 21:36:23 +0200 (mer., 21 avril 2010) | 3 lines Forgot to add the sample certificate (followup to r80314) ........
-rw-r--r--Lib/test/sha256.pem33
-rw-r--r--Lib/test/support.py11
-rw-r--r--Lib/test/test_ssl.py20
-rw-r--r--Misc/NEWS4
-rw-r--r--Modules/_ssl.c3
5 files changed, 70 insertions, 1 deletions
diff --git a/Lib/test/sha256.pem b/Lib/test/sha256.pem
new file mode 100644
index 0000000..01878e9
--- /dev/null
+++ b/Lib/test/sha256.pem
@@ -0,0 +1,33 @@
+-----BEGIN CERTIFICATE-----
+MIIFxzCCA6+gAwIBAgIJALnlnf5uzTkIMA0GCSqGSIb3DQEBCwUAMEsxCzAJBgNV
+BAYTAkRFMRcwFQYDVQQKEw5zY2hva29rZWtzLm9yZzEjMCEGCSqGSIb3DQEJARYU
+aGFubm9Ac2Nob2tva2Vrcy5vcmcwHhcNMTAwMTI3MDAyMTI1WhcNMjAwMTI1MDAy
+MTI1WjBLMQswCQYDVQQGEwJER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H/MA0GCSqGSIb3
+DQEBCwUAA4ICAQBHKAxA7WA/MEFjet03K8ouzEOr6Jrk2fZOuRhoDZ+9gr4FtaJB
+P3Hh5D00kuSOvDnwsvCohxeNd1KTMAwVmVoH+NZkHERn3UXniUENlp18koI1ehlr
+CZbXbzzE9Te9BelliSFA63q0cq0yJN1x9GyabU34XkAouCAmOqfSpKNZWZHGBHPF
+bbYnZrHEMcsye6vKeTOcg1GqUHGrQM2WK0QaOwnCQv2RblI9VN+SeRoUJ44qTXdW
+TwIYStsIPesacNcAQTStnHgKqIPx4zCwdx5xo8zONbXJfocqwyFqiAofvb9dN1nW
+g1noVBcXB+oRBZW5CjFw87U88itq39i9+BWl835DWLBW2pVmx1QTLGv0RNgs/xVx
+mWnjH4nNHvrjn6pRmqHZTk/SS0Hkl2qtDsynVxIl8EiMTfWSU3DBTuD2J/RSzuOE
+eKtAbaoXkXE31jCl4FEZLITIZd8UkXacb9rN304tAK92L76JOAV+xOZxFRipmvx4
++A9qQXgLhtP4VaDajb44V/kCKPSA0Vm3apehke9Wl8dDtagfos1e6MxSu3EVLXRF
+SP2U777V77pdMSd0f/7cerKn5FjrxW1v1FaP1oIGniMk4qQNTgA/jvvhjybsPlVA
+jsfnhWGbh1voJa0RQcMiRMsxpw2P1KNOEu37W2eq/vFghVztZJQUmb5iNw==
+-----END CERTIFICATE-----
diff --git a/Lib/test/support.py b/Lib/test/support.py
index 3c0002b..9d39de8 100644
--- a/Lib/test/support.py
+++ b/Lib/test/support.py
@@ -755,6 +755,17 @@ ioerror_peer_reset = TransientResource(IOError, errno=errno.ECONNRESET)
@contextlib.contextmanager
+def transient_internet():
+ """Return a context manager that raises ResourceDenied when various issues
+ with the Internet connection manifest themselves as exceptions."""
+ time_out = TransientResource(IOError, errno=errno.ETIMEDOUT)
+ socket_peer_reset = TransientResource(socket.error, errno=errno.ECONNRESET)
+ ioerror_peer_reset = TransientResource(IOError, errno=errno.ECONNRESET)
+ with time_out, socket_peer_reset, ioerror_peer_reset:
+ yield
+
+
+@contextlib.contextmanager
def captured_output(stream_name):
"""Run the 'with' statement body using a StringIO object in place of a
specific attribute on the sys module.
diff --git a/Lib/test/test_ssl.py b/Lib/test/test_ssl.py
index c1c59b5..77a5d6d 100644
--- a/Lib/test/test_ssl.py
+++ b/Lib/test/test_ssl.py
@@ -218,6 +218,26 @@ class NetworkedTests(unittest.TestCase):
if support.verbose:
sys.stdout.write("\nVerified certificate for svn.python.org:443 is\n%s\n" % pem)
+ def test_algorithms(self):
+ # Issue #8484: all algorithms should be available when verifying a
+ # certificate.
+ # NOTE: https://sha256.tbs-internet.com is another possible test host
+ remote = ("sha2.hboeck.de", 443)
+ sha256_cert = os.path.join(os.path.dirname(__file__), "sha256.pem")
+ s = ssl.wrap_socket(socket.socket(socket.AF_INET),
+ cert_reqs=ssl.CERT_REQUIRED,
+ ca_certs=sha256_cert,)
+ with support.transient_internet():
+ try:
+ s.connect(remote)
+ if support.verbose:
+ sys.stdout.write("\nCipher with %r is %r\n" %
+ (remote, s.cipher()))
+ sys.stdout.write("Certificate is:\n%s\n" %
+ pprint.pformat(s.getpeercert()))
+ finally:
+ s.close()
+
try:
import threading
diff --git a/Misc/NEWS b/Misc/NEWS
index 551e39d..381ea4e 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -318,6 +318,10 @@ C-API
Library
-------
+- Issue #8484: Load all ciphers and digest algorithms when initializing
+ the _ssl extension, such that verification of some SSL certificates
+ doesn't fail because of an "unknown algorithm".
+
- Issue #6547: Added the ignore_dangling_symlinks option to shutil.copytree.
- Issue #1540112: Now allowing the choice of a copy function in
diff --git a/Modules/_ssl.c b/Modules/_ssl.c
index 8784972..3232df5 100644
--- a/Modules/_ssl.c
+++ b/Modules/_ssl.c
@@ -1669,13 +1669,14 @@ PyInit__ssl(void)
/* Init OpenSSL */
SSL_load_error_strings();
+ SSL_library_init();
#ifdef WITH_THREAD
/* note that this will start threading if not already started */
if (!_setup_ssl_threads()) {
return NULL;
}
#endif
- SSLeay_add_ssl_algorithms();
+ OpenSSL_add_all_algorithms();
/* Add symbols to module dict */
PySSLErrorObject = PyErr_NewException("ssl.SSLError",