Scrapy, a fast high-level web crawling & scraping framework for Python.
Work around older pyOpenSSL not having get_cipher_name or get_protocol_version_name.
Andrey Rakhmatullin67a400092805
diff --git a/scrapy/core/downloader/tls.py b/scrapy/core/downloader/tls.pyindex 2ba72593f..7e5882663 100644--- a/scrapy/core/downloader/tls.py+++ b/scrapy/core/downloader/tls.py@@ -74,11 +74,18 @@ if twisted_version >= (14, 0, 0):if where & SSL_CB_HANDSHAKE_START:set_tlsext_host_name(connection, self._hostnameBytes)elif where & SSL_CB_HANDSHAKE_DONE:- logger.debug('SSL connection to %s using protocol %s, cipher %s',- self._hostnameASCII,- connection.get_protocol_version_name(),- connection.get_cipher_name(),- )+ if hasattr(connection, 'get_cipher_name'): # requires pyOPenSSL 0.15+ if hasattr(connection, 'get_protocol_version_name'): # requires pyOPenSSL 16.0.0+ logger.debug('SSL connection to %s using protocol %s, cipher %s',+ self._hostnameASCII,+ connection.get_protocol_version_name(),+ connection.get_cipher_name(),+ )+ else:+ logger.debug('SSL connection to %s using cipher %s',+ self._hostnameASCII,+ connection.get_cipher_name(),+ )server_cert = connection.get_peer_certificate()logger.debug('SSL connection certificate: issuer "%s", subject "%s"',x509name_to_string(server_cert.get_issuer()),