mirror of
https://github.com/pypa/pip
synced 2023-12-13 21:30:23 +01:00
Adding code to match_hostname.
This commit is contained in:
parent
39d84ab37b
commit
d54c695230
1 changed files with 9 additions and 4 deletions
|
@ -8,6 +8,10 @@ import re
|
|||
import shutil
|
||||
import socket
|
||||
import ssl
|
||||
try:
|
||||
from ssl import match_hostname
|
||||
except ImportError:
|
||||
from backports.ssl_match_hostname import match_hostname
|
||||
import sys
|
||||
import tempfile
|
||||
from pip.backwardcompat import (xmlrpclib, urllib, urllib2,
|
||||
|
@ -80,10 +84,11 @@ class VerifiedHTTPSConnection(httplib.HTTPSConnection):
|
|||
# certs in trusted_root_certs
|
||||
cert_path = os.path.join(os.path.dirname(__file__), 'cacert.pem')
|
||||
self.sock = ssl.wrap_socket(sock,
|
||||
self.key_file,
|
||||
self.cert_file,
|
||||
cert_reqs=ssl.CERT_REQUIRED,
|
||||
ca_certs=cert_path)
|
||||
self.key_file,
|
||||
self.cert_file,
|
||||
cert_reqs=ssl.CERT_REQUIRED,
|
||||
ca_certs=cert_path)
|
||||
match_hostname(self.sock.getpeercert(), self.host)
|
||||
|
||||
|
||||
# wraps https connections with ssl certificate verification
|
||||
|
|
Loading…
Reference in a new issue