Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(31278)

Side by Side Diff: Lib/http/client.py

Issue 22417: PEP 476: verify HTTPS certificates by default
Patch Set: Created 4 years, 7 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Doc/whatsnew/3.4.rst ('k') | Lib/ssl.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 """HTTP/1.1 client library 1 """HTTP/1.1 client library
2 2
3 <intro stuff goes here> 3 <intro stuff goes here>
4 <other stuff, too> 4 <other stuff, too>
5 5
6 HTTPConnection goes through a number of "states", which define when a client 6 HTTPConnection goes through a number of "states", which define when a client
7 may legally make another request or fetch the response for a particular 7 may legally make another request or fetch the response for a particular
8 request. This diagram details these state transitions: 8 request. This diagram details these state transitions:
9 9
10 (null) 10 (null)
(...skipping 1249 matching lines...) Expand 10 before | Expand all | Expand 10 after
1260 1260
1261 def __init__(self, host, port=None, key_file=None, cert_file=None, 1261 def __init__(self, host, port=None, key_file=None, cert_file=None,
1262 timeout=socket._GLOBAL_DEFAULT_TIMEOUT, 1262 timeout=socket._GLOBAL_DEFAULT_TIMEOUT,
1263 source_address=None, *, context=None, 1263 source_address=None, *, context=None,
1264 check_hostname=None): 1264 check_hostname=None):
1265 super(HTTPSConnection, self).__init__(host, port, timeout, 1265 super(HTTPSConnection, self).__init__(host, port, timeout,
1266 source_address) 1266 source_address)
1267 self.key_file = key_file 1267 self.key_file = key_file
1268 self.cert_file = cert_file 1268 self.cert_file = cert_file
1269 if context is None: 1269 if context is None:
1270 context = ssl._create_stdlib_context() 1270 context = ssl._create_default_https_context()
1271 will_verify = context.verify_mode != ssl.CERT_NONE 1271 will_verify = context.verify_mode != ssl.CERT_NONE
1272 if check_hostname is None: 1272 if check_hostname is None:
1273 check_hostname = will_verify 1273 check_hostname = will_verify
1274 elif check_hostname and not will_verify: 1274 elif check_hostname and not will_verify:
1275 raise ValueError("check_hostname needs a SSL context with " 1275 raise ValueError("check_hostname needs a SSL context with "
1276 "either CERT_OPTIONAL or CERT_REQUIRED") 1276 "either CERT_OPTIONAL or CERT_REQUIRED")
1277 if key_file or cert_file: 1277 if key_file or cert_file:
1278 context.load_cert_chain(cert_file, key_file) 1278 context.load_cert_chain(cert_file, key_file)
1279 self._context = context 1279 self._context = context
1280 self._check_hostname = check_hostname 1280 self._check_hostname = check_hostname
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
1358 self.args = line, 1358 self.args = line,
1359 self.line = line 1359 self.line = line
1360 1360
1361 class LineTooLong(HTTPException): 1361 class LineTooLong(HTTPException):
1362 def __init__(self, line_type): 1362 def __init__(self, line_type):
1363 HTTPException.__init__(self, "got more than %d bytes when reading %s" 1363 HTTPException.__init__(self, "got more than %d bytes when reading %s"
1364 % (_MAXLINE, line_type)) 1364 % (_MAXLINE, line_type))
1365 1365
1366 # for backwards compatibility 1366 # for backwards compatibility
1367 error = HTTPException 1367 error = HTTPException
OLDNEW
« no previous file with comments | « Doc/whatsnew/3.4.rst ('k') | Lib/ssl.py » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+