HTTPSConnection: prefer the context's check_hostname attribute over the constructor parameter (#22959)

This commit is contained in:
Benjamin Peterson 2014-12-07 13:18:25 -05:00
parent b92fd01189
commit a090f01bb6
4 changed files with 22 additions and 10 deletions

View file

@ -1210,8 +1210,8 @@ else:
context = ssl._create_default_https_context()
will_verify = context.verify_mode != ssl.CERT_NONE
if check_hostname is None:
check_hostname = will_verify
elif check_hostname and not will_verify:
check_hostname = context.check_hostname
if check_hostname and not will_verify:
raise ValueError("check_hostname needs a SSL context with "
"either CERT_OPTIONAL or CERT_REQUIRED")
if key_file or cert_file: