From dec0f6c8dcd47078bb8ed4f6720ab1ff8625f2f1 Mon Sep 17 00:00:00 2001 From: Bastian Kleineidam Date: Wed, 26 Mar 2014 12:38:16 +0100 Subject: [PATCH] Fix error with SNI checks --- doc/changelog.txt | 5 ++++- linkcheck/checker/httpurl.py | 5 +++-- linkcheck/plugins/sslcertcheck.py | 9 +++++---- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/doc/changelog.txt b/doc/changelog.txt index 2eb20b83..1feb03cb 100644 --- a/doc/changelog.txt +++ b/doc/changelog.txt @@ -14,7 +14,8 @@ Changes: - checking: Disable URL length warning for data: URLs. - checking: Do not warn about missing addresses on mailto links that have subjects. -- checking: Display SSL certificate info even on redirects. +- checking: Check and display SSL certificate info even on redirects. + Closes: GH bug #489 - installation: Check requirement for Python requests >= 2.2.0. Closes: GH bug #478 - logging: Display downloaded bytes. @@ -26,6 +27,8 @@ Fixes: - checking: Fix assertion in external link checking. - checking: Fix SSL errors on Windows. Closes: GH bug #471 +- checking: Fix error when SNI checks are enabled. + Closes: GH bug #488 - gui: Fix warning regex settings. Closes: GH bug #485 diff --git a/linkcheck/checker/httpurl.py b/linkcheck/checker/httpurl.py index 1a1b6776..837a8a58 100644 --- a/linkcheck/checker/httpurl.py +++ b/linkcheck/checker/httpurl.py @@ -199,8 +199,9 @@ class HttpUrl (internpaturl.InternPatternUrl, proxysupport.ProxySupport): """Add SSL cipher info.""" if self.scheme == u'https': sock = self._get_ssl_sock() - self.ssl_cipher = sock.cipher() - log.debug(LOG_CHECK, "Got SSL cipher %s", self.ssl_cipher) + if hasattr(sock, 'cipher'): + self.ssl_cipher = sock.cipher() + log.debug(LOG_CHECK, "Got SSL cipher %s", self.ssl_cipher) self.ssl_cert = sock.getpeercert() log.debug(LOG_CHECK, "Got SSL certificate %s", self.ssl_cert) else: diff --git a/linkcheck/plugins/sslcertcheck.py b/linkcheck/plugins/sslcertcheck.py index a3f65dd7..19f3799e 100644 --- a/linkcheck/plugins/sslcertcheck.py +++ b/linkcheck/plugins/sslcertcheck.py @@ -62,10 +62,11 @@ class SslCertificateCheck(_ConnectionPlugin): return self.checked_hosts.add(host) cert = url_data.ssl_cert - cipher_name, ssl_protocol, num_secret_bits = url_data.ssl_cipher - msg = _(u"SSL cipher %(cipher)s, %(protocol)s.") - attrs = dict(cipher=cipher_name, protocol=ssl_protocol) - url_data.add_info(msg % attrs) + if url_data.ssl_cipher is not None: + cipher_name, ssl_protocol, num_secret_bits = url_data.ssl_cipher + msg = _(u"SSL cipher %(cipher)s, %(protocol)s.") + attrs = dict(cipher=cipher_name, protocol=ssl_protocol) + url_data.add_info(msg % attrs) config = url_data.aggregate.config if cert and 'notAfter' in cert: self.check_ssl_valid_date(url_data, cert)