Fix misleading SSL error message
The `except` block with exception matching throught `if 'connection refused' in str(e).lower():` is funny, but is not user-friendly. Probably related issues: - #15679 - #12161 - #9966 - #8221 - #7218 ... and more
This commit is contained in:
parent
0ee9972903
commit
3fe8f70b08
1 changed files with 4 additions and 8 deletions
|
@ -721,15 +721,11 @@ class SSLValidationHandler(urllib_request.BaseHandler):
|
||||||
# close the ssl connection
|
# close the ssl connection
|
||||||
#ssl_s.unwrap()
|
#ssl_s.unwrap()
|
||||||
s.close()
|
s.close()
|
||||||
except (ssl.SSLError, socket.error):
|
except (ssl.SSLError, CertificateError):
|
||||||
e = get_exception()
|
|
||||||
# fail if we tried all of the certs but none worked
|
|
||||||
if 'connection refused' in str(e).lower():
|
|
||||||
raise ConnectionError('Failed to connect to %s:%s.' % (self.hostname, self.port))
|
|
||||||
else:
|
|
||||||
build_ssl_validation_error(self.hostname, self.port, paths_checked)
|
|
||||||
except CertificateError:
|
|
||||||
build_ssl_validation_error(self.hostname, self.port, paths_checked)
|
build_ssl_validation_error(self.hostname, self.port, paths_checked)
|
||||||
|
except socket.error:
|
||||||
|
e = get_exception()
|
||||||
|
raise ConnectionError('Failed to connect to %s at port %s: %s' % (self.hostname, self.port, str(e)))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# cleanup the temp file created, don't worry
|
# cleanup the temp file created, don't worry
|
||||||
|
|
Loading…
Reference in a new issue