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 shutil
|
||||||
import socket
|
import socket
|
||||||
import ssl
|
import ssl
|
||||||
|
try:
|
||||||
|
from ssl import match_hostname
|
||||||
|
except ImportError:
|
||||||
|
from backports.ssl_match_hostname import match_hostname
|
||||||
import sys
|
import sys
|
||||||
import tempfile
|
import tempfile
|
||||||
from pip.backwardcompat import (xmlrpclib, urllib, urllib2,
|
from pip.backwardcompat import (xmlrpclib, urllib, urllib2,
|
||||||
|
@ -80,10 +84,11 @@ class VerifiedHTTPSConnection(httplib.HTTPSConnection):
|
||||||
# certs in trusted_root_certs
|
# certs in trusted_root_certs
|
||||||
cert_path = os.path.join(os.path.dirname(__file__), 'cacert.pem')
|
cert_path = os.path.join(os.path.dirname(__file__), 'cacert.pem')
|
||||||
self.sock = ssl.wrap_socket(sock,
|
self.sock = ssl.wrap_socket(sock,
|
||||||
self.key_file,
|
self.key_file,
|
||||||
self.cert_file,
|
self.cert_file,
|
||||||
cert_reqs=ssl.CERT_REQUIRED,
|
cert_reqs=ssl.CERT_REQUIRED,
|
||||||
ca_certs=cert_path)
|
ca_certs=cert_path)
|
||||||
|
match_hostname(self.sock.getpeercert(), self.host)
|
||||||
|
|
||||||
|
|
||||||
# wraps https connections with ssl certificate verification
|
# wraps https connections with ssl certificate verification
|
||||||
|
|
Loading…
Reference in a new issue