Skip to content

Commit 89644d0

Browse files
committed
Issue python#25940: Backport self-signed.pythontest.net testing for test_httplib
The svn.python.org server recently changed root certificate, causing the test to fail. This backports revision 4985375db40f.
1 parent 5e62117 commit 89644d0

File tree

2 files changed

+24
-7
lines changed

2 files changed

+24
-7
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
-----BEGIN CERTIFICATE-----
2+
MIIChzCCAfCgAwIBAgIJAKGU95wKR8pSMA0GCSqGSIb3DQEBBQUAMHAxCzAJBgNV
3+
BAYTAlhZMRcwFQYDVQQHDA5DYXN0bGUgQW50aHJheDEjMCEGA1UECgwaUHl0aG9u
4+
IFNvZnR3YXJlIEZvdW5kYXRpb24xIzAhBgNVBAMMGnNlbGYtc2lnbmVkLnB5dGhv
5+
bnRlc3QubmV0MB4XDTE0MTEwMjE4MDkyOVoXDTI0MTAzMDE4MDkyOVowcDELMAkG
6+
A1UEBhMCWFkxFzAVBgNVBAcMDkNhc3RsZSBBbnRocmF4MSMwIQYDVQQKDBpQeXRo
7+
b24gU29mdHdhcmUgRm91bmRhdGlvbjEjMCEGA1UEAwwac2VsZi1zaWduZWQucHl0
8+
aG9udGVzdC5uZXQwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBANDXQXW9tjyZ
9+
Xt0Iv2tLL1+jinr4wGg36ioLDLFkMf+2Y1GL0v0BnKYG4N1OKlAU15LXGeGer8vm
10+
Sv/yIvmdrELvhAbbo3w4a9TMYQA4XkIVLdvu3mvNOAet+8PMJxn26dbDhG809ALv
11+
EHY57lQsBS3G59RZyBPVqAqmImWNJnVzAgMBAAGjKTAnMCUGA1UdEQQeMByCGnNl
12+
bGYtc2lnbmVkLnB5dGhvbnRlc3QubmV0MA0GCSqGSIb3DQEBBQUAA4GBAIOXmdtM
13+
eG9qzP9TiXW/Gc/zI4cBfdCpC+Y4gOfC9bQUC7hefix4iO3+iZjgy3X/FaRxUUoV
14+
HKiXcXIaWqTSUWp45cSh0MbwZXudp6JIAptzdAhvvCrPKeC9i9GvxsPD4LtDAL97
15+
vSaxQBezA7hdxZd90/EeyMgVZgAnTCnvAWX9
16+
-----END CERTIFICATE-----

Lib/test/test_httplib.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
CERT_localhost = os.path.join(here, 'keycert.pem')
1616
# Self-signed cert file for 'fakehostname'
1717
CERT_fakehostname = os.path.join(here, 'keycert2.pem')
18-
# Root cert file (CA) for svn.python.org's cert
19-
CACERT_svn_python_org = os.path.join(here, 'https_svn_python_org_root.pem')
18+
# Self-signed cert file for self-signed.pythontest.net
19+
CERT_selfsigned_pythontestdotnet = os.path.join(here, 'selfsigned_pythontestdotnet.pem')
2020

2121
HOST = support.HOST
2222

@@ -570,17 +570,18 @@ def test_networked(self):
570570
self._check_svn_python_org(resp)
571571

572572
def test_networked_good_cert(self):
573-
# We feed a CA cert that validates the server's cert
573+
# We feed the server's cert as a validating cert
574574
import ssl
575575
support.requires('network')
576-
with support.transient_internet('svn.python.org'):
576+
with support.transient_internet('self-signed.pythontest.net'):
577577
context = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
578578
context.verify_mode = ssl.CERT_REQUIRED
579-
context.load_verify_locations(CACERT_svn_python_org)
580-
h = client.HTTPSConnection('svn.python.org', 443, context=context)
579+
context.load_verify_locations(CERT_selfsigned_pythontestdotnet)
580+
h = client.HTTPSConnection('self-signed.pythontest.net', 443, context=context)
581581
h.request('GET', '/')
582582
resp = h.getresponse()
583-
self._check_svn_python_org(resp)
583+
server_string = resp.getheader('server')
584+
self.assertIn('nginx', server_string)
584585

585586
def test_networked_bad_cert(self):
586587
# We feed a "CA" cert that is unrelated to the server's cert

0 commit comments

Comments
 (0)