diff --git a/lib/interface.py b/lib/interface.py index 7531ecf9..b0843c40 100644 --- a/lib/interface.py +++ b/lib/interface.py @@ -201,8 +201,7 @@ class TcpInterface(threading.Thread): with open(cert_path) as f: cert = f.read() try: - x = x509.X509() - x.parseBinary(cert) + x = x509.X509(cert) except: traceback.print_exc(file=sys.stderr) self.print_error("wrong certificate") @@ -343,8 +342,7 @@ def check_host_name(peercert, name): def check_cert(host, cert): try: - x = x509.X509() - x.parseBinary(cert) + x = x509.X509(cert) except: traceback.print_exc(file=sys.stdout) return diff --git a/lib/paymentrequest.py b/lib/paymentrequest.py index 745e3af5..f2dbfe29 100644 --- a/lib/paymentrequest.py +++ b/lib/paymentrequest.py @@ -283,8 +283,7 @@ def verify_cert_chain(chain): cert_num = len(chain) x509_chain = [] for i in range(cert_num): - x = x509.X509() - x.parseBinary(bytearray(chain[i])) + x = x509.X509(bytearray(chain[i])) x509_chain.append(x) if i == 0: x.check_date() diff --git a/lib/x509.py b/lib/x509.py index 61c22ea1..3f722a16 100644 --- a/lib/x509.py +++ b/lib/x509.py @@ -49,7 +49,7 @@ class CertificateError(Exception): class X509(object): - def parseBinary(self, b): + def __init__(self, b): self.bytes = bytearray(b) @@ -178,9 +178,8 @@ def load_certificates(ca_path): s = f.read() bList = pem.dePemList(s, "CERTIFICATE") for b in bList: - x = X509() try: - x.parseBinary(b) + x = X509(b) x.check_date() except BaseException as e: util.print_error("cert error:", e)