1
1
Fork 0
mirror of https://github.com/pypa/pip synced 2023-12-13 21:30:23 +01:00

log relevant message if URLError.reason is SSLError or CertificateError

This commit is contained in:
Marcus Smith 2013-02-06 01:48:28 -08:00
parent 7e20fd83a2
commit b2e0b6dfb0
2 changed files with 7 additions and 4 deletions

View file

@ -113,12 +113,12 @@ def home_lib(home):
## py25 has no builtin ssl module
## only >=py32 has ssl.match_hostname
## only >=py32 has ssl.match_hostname and ssl.CertificateError
try:
import ssl
try:
from ssl import match_hostname
from ssl import match_hostname, CertificateError
except ImportError:
from backwardcompat_ssl import match_hostname
from backwardcompat_ssl import match_hostname, CertificateError
except ImportError:
ssl = None

View file

@ -22,7 +22,7 @@ from pip.exceptions import DistributionNotFound, BestVersionAlreadyInstalled
from pip.backwardcompat import (WindowsError, BytesIO,
Queue, urlparse,
URLError, HTTPError, u,
product, url2pathname)
product, url2pathname, ssl, CertificateError)
from pip.backwardcompat import Empty as QueueEmpty
from pip.download import urlopen, path_to_url2, url_to_path, geturl, Urllib2HeadRequest
@ -485,6 +485,9 @@ class HTMLPage(object):
level =1
desc = 'timed out'
elif isinstance(e, URLError):
#ssl/certificate error
if hasattr(e, 'reason') and (isinstance(e.reason, ssl.SSLError) or isinstance(e.reason, CertificateError)):
desc = 'there was a problem confirming the ssl certificate %s' % e
log_meth = logger.info
if hasattr(e, 'reason') and isinstance(e.reason, socket.timeout):
desc = 'timed out'