mirror of
https://github.com/python/cpython.git
synced 2025-08-30 21:48:47 +00:00
merge with 3.4
This commit is contained in:
commit
dca213dd77
2 changed files with 24 additions and 12 deletions
|
@ -15,8 +15,8 @@ here = os.path.dirname(__file__)
|
|||
CERT_localhost = os.path.join(here, 'keycert.pem')
|
||||
# Self-signed cert file for 'fakehostname'
|
||||
CERT_fakehostname = os.path.join(here, 'keycert2.pem')
|
||||
# Root cert file (CA) for svn.python.org's cert
|
||||
CACERT_svn_python_org = os.path.join(here, 'https_svn_python_org_root.pem')
|
||||
# Self-signed cert file for self-signed.pythontest.net
|
||||
CERT_selfsigned_pythontestdotnet = os.path.join(here, 'selfsigned_pythontestdotnet.pem')
|
||||
|
||||
# constants for testing chunked encoding
|
||||
chunked_start = (
|
||||
|
@ -1006,11 +1006,6 @@ class HTTPSTest(TestCase):
|
|||
h = client.HTTPSConnection(HOST, TimeoutTest.PORT, timeout=30)
|
||||
self.assertEqual(h.timeout, 30)
|
||||
|
||||
def _check_svn_python_org(self, resp):
|
||||
# Just a simple check that everything went fine
|
||||
server_string = resp.getheader('server')
|
||||
self.assertIn('Apache', server_string)
|
||||
|
||||
def test_networked(self):
|
||||
# Default settings: requires a valid cert from a trusted CA
|
||||
import ssl
|
||||
|
@ -1044,17 +1039,18 @@ class HTTPSTest(TestCase):
|
|||
self.assertIn('text/html', content_type)
|
||||
|
||||
def test_networked_good_cert(self):
|
||||
# We feed a CA cert that validates the server's cert
|
||||
# We feed the server's cert as a validating cert
|
||||
import ssl
|
||||
support.requires('network')
|
||||
with support.transient_internet('svn.python.org'):
|
||||
with support.transient_internet('self-signed.pythontest.net'):
|
||||
context = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
|
||||
context.verify_mode = ssl.CERT_REQUIRED
|
||||
context.load_verify_locations(CACERT_svn_python_org)
|
||||
h = client.HTTPSConnection('svn.python.org', 443, context=context)
|
||||
context.load_verify_locations(CERT_selfsigned_pythontestdotnet)
|
||||
h = client.HTTPSConnection('self-signed.pythontest.net', 443, context=context)
|
||||
h.request('GET', '/')
|
||||
resp = h.getresponse()
|
||||
self._check_svn_python_org(resp)
|
||||
server_string = resp.getheader('server')
|
||||
self.assertIn('nginx', server_string)
|
||||
|
||||
def test_networked_bad_cert(self):
|
||||
# We feed a "CA" cert that is unrelated to the server's cert
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue