mirror of
https://github.com/scrapy/scrapy.git
synced 2025-02-23 09:24:04 +00:00
Remove import check for service_identity
service_identity.exceptions.CertificateError is available in the current minimum version (16.0.0)
This commit is contained in:
parent
3164543ed1
commit
b404941e0d
@ -1,8 +1,9 @@
|
||||
import logging
|
||||
|
||||
from OpenSSL import SSL
|
||||
from twisted.internet.ssl import AcceptableCiphers
|
||||
from service_identity.exceptions import CertificateError
|
||||
from twisted.internet._sslverify import ClientTLSOptions, verifyHostname, VerificationError
|
||||
from twisted.internet.ssl import AcceptableCiphers
|
||||
|
||||
from scrapy import twisted_version
|
||||
from scrapy.utils.ssl import x509name_to_string, get_temp_key_info
|
||||
@ -27,15 +28,6 @@ openssl_methods = {
|
||||
}
|
||||
|
||||
|
||||
try:
|
||||
# XXX: this import would fail on Debian jessie with system installed
|
||||
# service_identity library, due to lack of cryptography.x509 dependency
|
||||
# See https://github.com/pyca/service_identity/issues/21
|
||||
from service_identity.exceptions import CertificateError
|
||||
verification_errors = (CertificateError, VerificationError)
|
||||
except ImportError:
|
||||
verification_errors = VerificationError
|
||||
|
||||
if twisted_version < (17, 0, 0):
|
||||
from twisted.internet._sslverify import _maybeSetHostNameIndication
|
||||
set_tlsext_host_name = _maybeSetHostNameIndication
|
||||
@ -87,7 +79,7 @@ class ScrapyClientTLSOptions(ClientTLSOptions):
|
||||
|
||||
try:
|
||||
verifyHostname(connection, self._hostnameASCII)
|
||||
except verification_errors as e:
|
||||
except (CertificateError, VerificationError) as e:
|
||||
logger.warning(
|
||||
'Remote certificate is not valid for hostname "{}"; {}'.format(
|
||||
self._hostnameASCII, e))
|
||||
|
Loading…
x
Reference in New Issue
Block a user