Scrapy, a fast high-level web crawling & scraping framework for Python.
catch CertificateError in tls verification
Lucy Wang13a74d77e2e4
diff --git a/scrapy/core/downloader/tls.py b/scrapy/core/downloader/tls.pyindex 498e3d60f..e1c4f4908 100644--- a/scrapy/core/downloader/tls.py+++ b/scrapy/core/downloader/tls.py@@ -40,6 +40,7 @@ if twisted_version >= (14, 0, 0):from twisted.internet._sslverify import (ClientTLSOptions,verifyHostname,VerificationError)+ from service_identity.exceptions import CertificateErrorif 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))