Skip to content

Commit fbaf931

Browse files
committed
test_httplib: use self-signed.pythontest.net for verification test with non-root-CA cert
1 parent 50219fc commit fbaf931

File tree

2 files changed

+24
-12
lines changed

2 files changed

+24
-12
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 & 12 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

@@ -772,11 +772,6 @@ def test_attributes(self):
772772
h = client.HTTPSConnection(HOST, TimeoutTest.PORT, timeout=30)
773773
self.assertEqual(h.timeout, 30)
774774

775-
def _check_svn_python_org(self, resp):
776-
# Just a simple check that everything went fine
777-
server_string = resp.getheader('server')
778-
self.assertIn('Apache', server_string)
779-
780775
def test_networked(self):
781776
# Default settings: requires a valid cert from a trusted CA
782777
import ssl
@@ -810,17 +805,18 @@ def test_networked_trusted_by_default_cert(self):
810805
self.assertIn('text/html', content_type)
811806

812807
def test_networked_good_cert(self):
813-
# We feed a CA cert that validates the server's cert
808+
# We feed the server's cert as a validating cert
814809
import ssl
815810
support.requires('network')
816-
with support.transient_internet('svn.python.org'):
811+
with support.transient_internet('self-signed.pythontest.net'):
817812
context = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
818813
context.verify_mode = ssl.CERT_REQUIRED
819-
context.load_verify_locations(CACERT_svn_python_org)
820-
h = client.HTTPSConnection('svn.python.org', 443, context=context)
814+
context.load_verify_locations(CERT_selfsigned_pythontestdotnet)
815+
h = client.HTTPSConnection('self-signed.pythontest.net', 443, context=context)
821816
h.request('GET', '/')
822817
resp = h.getresponse()
823-
self._check_svn_python_org(resp)
818+
server_string = resp.getheader('server')
819+
self.assertIn('nginx', server_string)
824820

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

0 commit comments

Comments
 (0)