mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-23 08:11:00 +00:00
CertStore: cope with certs that have no common name
This commit is contained in:
parent
86730a9a4c
commit
52b14aa1d1
@ -169,20 +169,21 @@ class CertStore:
|
|||||||
f.close()
|
f.close()
|
||||||
return key, ca
|
return key, ca
|
||||||
|
|
||||||
def add_cert_file(self, commonname, path):
|
def add_cert_file(self, spec, path):
|
||||||
raw = file(path, "rb").read()
|
raw = file(path, "rb").read()
|
||||||
cert = OpenSSL.crypto.load_certificate(OpenSSL.crypto.FILETYPE_PEM, raw)
|
cert = OpenSSL.crypto.load_certificate(OpenSSL.crypto.FILETYPE_PEM, raw)
|
||||||
try:
|
try:
|
||||||
privkey = OpenSSL.crypto.load_privatekey(OpenSSL.crypto.FILETYPE_PEM, raw)
|
privkey = OpenSSL.crypto.load_privatekey(OpenSSL.crypto.FILETYPE_PEM, raw)
|
||||||
except Exception:
|
except Exception:
|
||||||
privkey = None
|
privkey = None
|
||||||
self.add_cert(SSLCert(cert), privkey, commonname)
|
self.add_cert(SSLCert(cert), privkey, spec)
|
||||||
|
|
||||||
def add_cert(self, cert, privkey, *names):
|
def add_cert(self, cert, privkey, *names):
|
||||||
"""
|
"""
|
||||||
Adds a cert to the certstore. We register the CN in the cert plus
|
Adds a cert to the certstore. We register the CN in the cert plus
|
||||||
any SANs, and also the list of names provided as an argument.
|
any SANs, and also the list of names provided as an argument.
|
||||||
"""
|
"""
|
||||||
|
if cert.cn:
|
||||||
self.certs.add(cert.cn, (cert, privkey))
|
self.certs.add(cert.cn, (cert, privkey))
|
||||||
for i in cert.altnames:
|
for i in cert.altnames:
|
||||||
self.certs.add(i, (cert, privkey))
|
self.certs.add(i, (cert, privkey))
|
||||||
|
Loading…
Reference in New Issue
Block a user