From 7bea1cce1fbb0e0a502288b381ce12fbc1e93dd7 Mon Sep 17 00:00:00 2001 From: SomberNight Date: Fri, 26 Apr 2019 01:55:58 +0200 Subject: [PATCH] x509: show cert expiration date in error related #5292 --- electrum/x509.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/electrum/x509.py b/electrum/x509.py index 6e519cada..8a901d3a3 100644 --- a/electrum/x509.py +++ b/electrum/x509.py @@ -25,6 +25,7 @@ import hashlib import time +from datetime import datetime import ecdsa @@ -304,7 +305,8 @@ class X509(object): if self.notBefore > now: raise CertificateError('Certificate has not entered its valid date range. (%s)' % self.get_common_name()) if self.notAfter <= now: - raise CertificateError('Certificate has expired. (%s)' % self.get_common_name()) + dt = datetime.utcfromtimestamp(time.mktime(self.notAfter)) + raise CertificateError(f'Certificate ({self.get_common_name()}) has expired (at {dt} UTC).') def getFingerprint(self): return hashlib.sha1(self.bytes).digest()