mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
gh-105382: Remove urllib.request cafile parameter (#105384)
Remove cafile, capath and cadefault parameters of the urllib.request.urlopen() function, deprecated in Python 3.6.
This commit is contained in:
parent
94d5f9827d
commit
2587b9f64e
6 changed files with 17 additions and 77 deletions
|
@ -568,31 +568,6 @@ class TestUrlopen(unittest.TestCase):
|
|||
data = self.urlopen("https://localhost:%s/bizarre" % handler.port, context=context)
|
||||
self.assertEqual(data, b"we care a bit")
|
||||
|
||||
def test_https_with_cafile(self):
|
||||
handler = self.start_https_server(certfile=CERT_localhost)
|
||||
with warnings_helper.check_warnings(('', DeprecationWarning)):
|
||||
# Good cert
|
||||
data = self.urlopen("https://localhost:%s/bizarre" % handler.port,
|
||||
cafile=CERT_localhost)
|
||||
self.assertEqual(data, b"we care a bit")
|
||||
# Bad cert
|
||||
with self.assertRaises(urllib.error.URLError) as cm:
|
||||
self.urlopen("https://localhost:%s/bizarre" % handler.port,
|
||||
cafile=CERT_fakehostname)
|
||||
# Good cert, but mismatching hostname
|
||||
handler = self.start_https_server(certfile=CERT_fakehostname)
|
||||
with self.assertRaises(urllib.error.URLError) as cm:
|
||||
self.urlopen("https://localhost:%s/bizarre" % handler.port,
|
||||
cafile=CERT_fakehostname)
|
||||
|
||||
def test_https_with_cadefault(self):
|
||||
handler = self.start_https_server(certfile=CERT_localhost)
|
||||
# Self-signed cert should fail verification with system certificate store
|
||||
with warnings_helper.check_warnings(('', DeprecationWarning)):
|
||||
with self.assertRaises(urllib.error.URLError) as cm:
|
||||
self.urlopen("https://localhost:%s/bizarre" % handler.port,
|
||||
cadefault=True)
|
||||
|
||||
def test_https_sni(self):
|
||||
if ssl is None:
|
||||
self.skipTest("ssl module required")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue