URI: 
       tsimplify x509 constructor - electrum - Electrum Bitcoin wallet
  HTML git clone https://git.parazyd.org/electrum
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
       ---
   DIR commit ca3c320ef42839f373ff1f9e00d6756a444419d7
   DIR parent 713fa00d8626333501895e7350031e22b7ae0ada
  HTML Author: ThomasV <thomasv@gitorious>
       Date:   Fri,  7 Aug 2015 11:39:30 +0200
       
       simplify x509 constructor
       
       Diffstat:
         M lib/interface.py                    |       6 ++----
         M lib/paymentrequest.py               |       3 +--
         M lib/x509.py                         |       5 ++---
       
       3 files changed, 5 insertions(+), 9 deletions(-)
       ---
   DIR diff --git a/lib/interface.py b/lib/interface.py
       t@@ -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")
       t@@ -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
   DIR diff --git a/lib/paymentrequest.py b/lib/paymentrequest.py
       t@@ -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()
   DIR diff --git a/lib/x509.py b/lib/x509.py
       t@@ -49,7 +49,7 @@ class CertificateError(Exception):
        
        class X509(object):
        
       -    def parseBinary(self, b):
       +    def __init__(self, b):
        
                self.bytes = bytearray(b)
        
       t@@ -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)