Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fec12ff

Browse files
committed
Merged revisions 80314-80315 via svnmerge from
svn+ssh://[email protected]/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) ........
1 parent e7ed1d7 commit fec12ff

5 files changed

Lines changed: 70 additions & 1 deletion

File tree

Lib/test/sha256.pem

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
-----BEGIN CERTIFICATE-----
2+
MIIFxzCCA6+gAwIBAgIJALnlnf5uzTkIMA0GCSqGSIb3DQEBCwUAMEsxCzAJBgNV
3+
BAYTAkRFMRcwFQYDVQQKEw5zY2hva29rZWtzLm9yZzEjMCEGCSqGSIb3DQEJARYU
4+
aGFubm9Ac2Nob2tva2Vrcy5vcmcwHhcNMTAwMTI3MDAyMTI1WhcNMjAwMTI1MDAy
5+
MTI1WjBLMQswCQYDVQQGEwJERTEXMBUGA1UEChMOc2Nob2tva2Vrcy5vcmcxIzAh
6+
BgkqhkiG9w0BCQEWFGhhbm5vQHNjaG9rb2tla3Mub3JnMIICIjANBgkqhkiG9w0B
7+
AQEFAAOCAg8AMIICCgKCAgEApJ4ODPwEooMW35dQPlBqdvcfkEvjhcsA7jmJfFqN
8+
e/1T34zT44X9+KnMBSG2InacbD7eyFgjfaENFsZ87YkEBDIFZ/SHotLJZORQ8PUj
9+
YoxPG4mjKN+yL2WthNcYbRyJreTbbDroNMuw6tkTSxeSXyYFQrKMCUfErVbZa/d5
10+
RvfFVk+Au9dVUFhed/Stn5cv+a0ffvpyA7ygihm1kMFICbvPeI0846tmC2Ph7rM5
11+
pYQyNBDOVpULODTk5Wu6j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5CjFw87U88itq39i9+BWl835DWLBW2pVmx1QTLGv0RNgs/xVx
28+
mWnjH4nNHvrjn6pRmqHZTk/SS0Hkl2qtDsynVxIl8EiMTfWSU3DBTuD2J/RSzuOE
29+
eKtAbaoXkXE31jCl4FEZLITIZd8UkXacb9rN304tAK92L76JOAV+xOZxFRipmvx4
30+
+A9qQXgLhtP4VaDajb44V/kCKPSA0Vm3apehke9Wl8dDtagfos1e6MxSu3EVLXRF
31+
SP2U777V77pdMSd0f/7cerKn5FjrxW1v1FaP1oIGniMk4qQNTgA/jvvhjybsPlVA
32+
jsfnhWGbh1voJa0RQcMiRMsxpw2P1KNOEu37W2eq/vFghVztZJQUmb5iNw==
33+
-----END CERTIFICATE-----

Lib/test/support.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -754,6 +754,17 @@ def __exit__(self, type_=None, value=None, traceback=None):
754754
ioerror_peer_reset = TransientResource(IOError, errno=errno.ECONNRESET)
755755

756756

757+
@contextlib.contextmanager
758+
def transient_internet():
759+
"""Return a context manager that raises ResourceDenied when various issues
760+
with the Internet connection manifest themselves as exceptions."""
761+
time_out = TransientResource(IOError, errno=errno.ETIMEDOUT)
762+
socket_peer_reset = TransientResource(socket.error, errno=errno.ECONNRESET)
763+
ioerror_peer_reset = TransientResource(IOError, errno=errno.ECONNRESET)
764+
with time_out, socket_peer_reset, ioerror_peer_reset:
765+
yield
766+
767+
757768
@contextlib.contextmanager
758769
def captured_output(stream_name):
759770
"""Run the 'with' statement body using a StringIO object in place of a

Lib/test/test_ssl.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,26 @@ def testFetchServerCert(self):
218218
if support.verbose:
219219
sys.stdout.write("\nVerified certificate for svn.python.org:443 is\n%s\n" % pem)
220220

221+
def test_algorithms(self):
222+
# Issue #8484: all algorithms should be available when verifying a
223+
# certificate.
224+
# NOTE: https://sha256.tbs-internet.com is another possible test host
225+
remote = ("sha2.hboeck.de", 443)
226+
sha256_cert = os.path.join(os.path.dirname(__file__), "sha256.pem")
227+
s = ssl.wrap_socket(socket.socket(socket.AF_INET),
228+
cert_reqs=ssl.CERT_REQUIRED,
229+
ca_certs=sha256_cert,)
230+
with support.transient_internet():
231+
try:
232+
s.connect(remote)
233+
if support.verbose:
234+
sys.stdout.write("\nCipher with %r is %r\n" %
235+
(remote, s.cipher()))
236+
sys.stdout.write("Certificate is:\n%s\n" %
237+
pprint.pformat(s.getpeercert()))
238+
finally:
239+
s.close()
240+
221241

222242
try:
223243
import threading

Misc/NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,10 @@ C-API
318318
Library
319319
-------
320320

321+
- Issue #8484: Load all ciphers and digest algorithms when initializing
322+
the _ssl extension, such that verification of some SSL certificates
323+
doesn't fail because of an "unknown algorithm".
324+
321325
- Issue #6547: Added the ignore_dangling_symlinks option to shutil.copytree.
322326

323327
- Issue #1540112: Now allowing the choice of a copy function in

Modules/_ssl.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1669,13 +1669,14 @@ PyInit__ssl(void)
16691669

16701670
/* Init OpenSSL */
16711671
SSL_load_error_strings();
1672+
SSL_library_init();
16721673
#ifdef WITH_THREAD
16731674
/* note that this will start threading if not already started */
16741675
if (!_setup_ssl_threads()) {
16751676
return NULL;
16761677
}
16771678
#endif
1678-
SSLeay_add_ssl_algorithms();
1679+
OpenSSL_add_all_algorithms();
16791680

16801681
/* Add symbols to module dict */
16811682
PySSLErrorObject = PyErr_NewException("ssl.SSLError",

0 commit comments

Comments
 (0)