From b26d75a6a88c5763fb6ee71f6c20039210f39145 Mon Sep 17 00:00:00 2001 From: James Lu Date: Fri, 15 Jun 2018 15:50:32 -0700 Subject: [PATCH] IRCNetwork: handle the case when certificate fingerprint checking is on but the remote provides no cert --- classes.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/classes.py b/classes.py index f73f3e9..6940b9d 100644 --- a/classes.py +++ b/classes.py @@ -1642,8 +1642,12 @@ class IRCNetwork(PyLinkNetworkCoreWithUtils): raise conf.ConfigurationError('Unsupported or invalid TLS/SSL certificate fingerprint type %r', hashtype) else: - fp = hashfunc(peercert).hexdigest() expected_fp = self.serverdata.get('ssl_fingerprint') + if expected_fp and peercert is None: + raise ssl.CertificateError('TLS/SSL certificate fingerprint checking is enabled but the uplink ' + 'did not provide a certificate') + + fp = hashfunc(peercert).hexdigest() if expected_fp: if fp != expected_fp: