mirror of
https://github.com/python/cpython.git
synced 2024-11-23 18:04:37 +08:00
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) ........
This commit is contained in:
parent
e7ed1d7f68
commit
fec12fff0f
33
Lib/test/sha256.pem
Normal file
33
Lib/test/sha256.pem
Normal file
@ -0,0 +1,33 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIFxzCCA6+gAwIBAgIJALnlnf5uzTkIMA0GCSqGSIb3DQEBCwUAMEsxCzAJBgNV
|
||||
BAYTAkRFMRcwFQYDVQQKEw5zY2hva29rZWtzLm9yZzEjMCEGCSqGSIb3DQEJARYU
|
||||
aGFubm9Ac2Nob2tva2Vrcy5vcmcwHhcNMTAwMTI3MDAyMTI1WhcNMjAwMTI1MDAy
|
||||
MTI1WjBLMQswCQYDVQQGEwJERTEXMBUGA1UEChMOc2Nob2tva2Vrcy5vcmcxIzAh
|
||||
BgkqhkiG9w0BCQEWFGhhbm5vQHNjaG9rb2tla3Mub3JnMIICIjANBgkqhkiG9w0B
|
||||
AQEFAAOCAg8AMIICCgKCAgEApJ4ODPwEooMW35dQPlBqdvcfkEvjhcsA7jmJfFqN
|
||||
e/1T34zT44X9+KnMBSG2InacbD7eyFgjfaENFsZ87YkEBDIFZ/SHotLJZORQ8PUj
|
||||
YoxPG4mjKN+yL2WthNcYbRyJreTbbDroNMuw6tkTSxeSXyYFQrKMCUfErVbZa/d5
|
||||
RvfFVk+Au9dVUFhed/Stn5cv+a0ffvpyA7ygihm1kMFICbvPeI0846tmC2Ph7rM5
|
||||
pYQyNBDOVpULODTk5Wu6jiiJJyg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b9dN1nW
|
||||
g1noVBcXB+oRBZW5CjFw87U88itq39i9+BWl835DWLBW2pVmx1QTLGv0RNgs/xVx
|
||||
mWnjH4nNHvrjn6pRmqHZTk/SS0Hkl2qtDsynVxIl8EiMTfWSU3DBTuD2J/RSzuOE
|
||||
eKtAbaoXkXE31jCl4FEZLITIZd8UkXacb9rN304tAK92L76JOAV+xOZxFRipmvx4
|
||||
+A9qQXgLhtP4VaDajb44V/kCKPSA0Vm3apehke9Wl8dDtagfos1e6MxSu3EVLXRF
|
||||
SP2U777V77pdMSd0f/7cerKn5FjrxW1v1FaP1oIGniMk4qQNTgA/jvvhjybsPlVA
|
||||
jsfnhWGbh1voJa0RQcMiRMsxpw2P1KNOEu37W2eq/vFghVztZJQUmb5iNw==
|
||||
-----END CERTIFICATE-----
|
@ -754,6 +754,17 @@ socket_peer_reset = TransientResource(socket.error, errno=errno.ECONNRESET)
|
||||
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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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",
|
||||
|
Loading…
Reference in New Issue
Block a user