Socket: fix crash on Python versions that do no support certificate validation.

This commit is contained in:
Valentin Lorentz 2016-02-23 16:25:37 +01:00
parent 880addf256
commit 78cf550674

View File

@ -374,7 +374,9 @@ class SocketDriver(drivers.IrcDriver, drivers.ServersMixin):
verify=verifyCertificates, verify=verifyCertificates,
trusted_fingerprints=network_config.ssl.serverFingerprints(), trusted_fingerprints=network_config.ssl.serverFingerprints(),
) )
except ssl.CertificateError as e: except getattr(ssl, 'CertificateError', None) as e:
# Default to None for old Python version, which do not have
# CertificateError
drivers.log.critical(('Certificate validation failed when ' drivers.log.critical(('Certificate validation failed when '
'connecting to %s: %s\n' 'connecting to %s: %s\n'
'This means someone is doing a man-in-the-middle attack ' 'This means someone is doing a man-in-the-middle attack '