1
0
mirror of https://github.com/scrapy/scrapy.git synced 2025-02-24 16:44:19 +00:00

catch CertificateError in tls verification

This commit is contained in:
Lucy Wang 2018-03-12 22:25:19 +08:00
parent acd2b8d43b
commit 13a74d77e2

View File

@ -40,6 +40,7 @@ if twisted_version >= (14, 0, 0):
from twisted.internet._sslverify import (ClientTLSOptions,
verifyHostname,
VerificationError)
from service_identity.exceptions import CertificateError
if twisted_version < (17, 0, 0):
from twisted.internet._sslverify import _maybeSetHostNameIndication
@ -65,7 +66,7 @@ if twisted_version >= (14, 0, 0):
elif where & SSL_CB_HANDSHAKE_DONE:
try:
verifyHostname(connection, self._hostnameASCII)
except VerificationError as e:
except (CertificateError, VerificationError) as e:
logger.warning(
'Remote certificate is not valid for hostname "{}"; {}'.format(
self._hostnameASCII, e))