electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 6d38c411d1d92d591cdd5c87950a129613f6b1bd
parent ac53bc50895878ef628e83c2ebbe15ec1016227b
Author: ThomasV <thomasv@electrum.org>
Date:   Thu, 23 Feb 2017 08:55:47 +0100

lazy load certificates

Diffstat:
Mlib/paymentrequest.py | 11++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/lib/paymentrequest.py b/lib/paymentrequest.py @@ -53,7 +53,14 @@ REQUEST_HEADERS = {'Accept': 'application/bitcoin-paymentrequest', 'User-Agent': ACK_HEADERS = {'Content-Type':'application/bitcoin-payment','Accept':'application/bitcoin-paymentack','User-Agent':'Electrum'} ca_path = requests.certs.where() -ca_list, ca_keyID = x509.load_certificates(ca_path) +ca_list = None +ca_keyID = None + +def load_ca_list(): + global ca_list, ca_keyID + if ca_list is None: + ca_list, ca_keyID = x509.load_certificates(ca_path) + # status of payment requests @@ -155,6 +162,7 @@ class PaymentRequest: return False def verify_x509(self, paymntreq): + load_ca_list() if not ca_list: self.error = "Trusted certificate authorities list not found" return False @@ -334,6 +342,7 @@ def sign_request_with_alias(pr, alias, alias_privkey): def verify_cert_chain(chain): """ Verify a chain of certificates. The last certificate is the CA""" + load_ca_list() # parse the chain cert_num = len(chain) x509_chain = []