add file: scheme to get_payment_request
This commit is contained in:
parent
9fde706f84
commit
f6a00fdb34
|
@ -59,11 +59,16 @@ import json
|
||||||
|
|
||||||
def get_payment_request(url):
|
def get_payment_request(url):
|
||||||
u = urlparse.urlparse(url)
|
u = urlparse.urlparse(url)
|
||||||
domain = u.netloc
|
if u.scheme in ['http', 'https']:
|
||||||
connection = httplib.HTTPConnection(u.netloc) if u.scheme == 'http' else httplib.HTTPSConnection(u.netloc)
|
connection = httplib.HTTPConnection(u.netloc) if u.scheme == 'http' else httplib.HTTPSConnection(u.netloc)
|
||||||
connection.request("GET", u.geturl(), headers=REQUEST_HEADERS)
|
connection.request("GET", u.geturl(), headers=REQUEST_HEADERS)
|
||||||
response = connection.getresponse()
|
response = connection.getresponse()
|
||||||
data = response.read()
|
data = response.read()
|
||||||
|
elif u.scheme == 'file':
|
||||||
|
with open(u.path, 'r') as f:
|
||||||
|
data = f.read()
|
||||||
|
else:
|
||||||
|
raise BaseException("unknown scheme", url)
|
||||||
pr = PaymentRequest(data)
|
pr = PaymentRequest(data)
|
||||||
return pr
|
return pr
|
||||||
|
|
||||||
|
@ -127,6 +132,8 @@ class PaymentRequest:
|
||||||
self.error = str(e)
|
self.error = str(e)
|
||||||
return
|
return
|
||||||
self.domain = x.get_common_name()
|
self.domain = x.get_common_name()
|
||||||
|
if self.domain.startswith('*.'):
|
||||||
|
self.domain = self.domain[2:]
|
||||||
else:
|
else:
|
||||||
if not x.check_ca():
|
if not x.check_ca():
|
||||||
self.error = "ERROR: Supplied CA Certificate Error"
|
self.error = "ERROR: Supplied CA Certificate Error"
|
||||||
|
@ -201,7 +208,7 @@ class PaymentRequest:
|
||||||
self.error = "ERROR: Invalid Signature for Payment Request Data"
|
self.error = "ERROR: Invalid Signature for Payment Request Data"
|
||||||
return False
|
return False
|
||||||
### SIG Verified
|
### SIG Verified
|
||||||
self.error = 'Signed by Trusted CA: ' + ca.extract_names()['OU']
|
self.error = 'Signed by Trusted CA: ' + ca.get_common_name()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def has_expired(self):
|
def has_expired(self):
|
||||||
|
|
Loading…
Reference in New Issue