lazy load certificates
This commit is contained in:
parent
ac53bc5089
commit
6d38c411d1
|
@ -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'}
|
ACK_HEADERS = {'Content-Type':'application/bitcoin-payment','Accept':'application/bitcoin-paymentack','User-Agent':'Electrum'}
|
||||||
|
|
||||||
ca_path = requests.certs.where()
|
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
|
# status of payment requests
|
||||||
|
@ -155,6 +162,7 @@ class PaymentRequest:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def verify_x509(self, paymntreq):
|
def verify_x509(self, paymntreq):
|
||||||
|
load_ca_list()
|
||||||
if not ca_list:
|
if not ca_list:
|
||||||
self.error = "Trusted certificate authorities list not found"
|
self.error = "Trusted certificate authorities list not found"
|
||||||
return False
|
return False
|
||||||
|
@ -334,6 +342,7 @@ def sign_request_with_alias(pr, alias, alias_privkey):
|
||||||
|
|
||||||
def verify_cert_chain(chain):
|
def verify_cert_chain(chain):
|
||||||
""" Verify a chain of certificates. The last certificate is the CA"""
|
""" Verify a chain of certificates. The last certificate is the CA"""
|
||||||
|
load_ca_list()
|
||||||
# parse the chain
|
# parse the chain
|
||||||
cert_num = len(chain)
|
cert_num = len(chain)
|
||||||
x509_chain = []
|
x509_chain = []
|
||||||
|
|
Loading…
Reference in New Issue