aboutsummaryrefslogtreecommitdiffstats
path: root/netlib
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2014-03-05 17:29:14 +1300
committerAldo Cortesi <aldo@nullcube.com>2014-03-05 17:29:14 +1300
commit52b14aa1d1bbeb3e2b8c62ee9939b9575ee1840f (patch)
treec124acad8651d05bd90b58a455c202cab1b11922 /netlib
parent86730a9a4c3a14b510590aa97a8ae8989cb6ec5e (diff)
downloadmitmproxy-52b14aa1d1bbeb3e2b8c62ee9939b9575ee1840f.tar.gz
mitmproxy-52b14aa1d1bbeb3e2b8c62ee9939b9575ee1840f.tar.bz2
mitmproxy-52b14aa1d1bbeb3e2b8c62ee9939b9575ee1840f.zip
CertStore: cope with certs that have no common name
Diffstat (limited to 'netlib')
-rw-r--r--netlib/certutils.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/netlib/certutils.py b/netlib/certutils.py
index fafcb5fd..d544cfa6 100644
--- a/netlib/certutils.py
+++ b/netlib/certutils.py
@@ -169,21 +169,22 @@ class CertStore:
f.close()
return key, ca
- def add_cert_file(self, commonname, path):
+ def add_cert_file(self, spec, path):
raw = file(path, "rb").read()
cert = OpenSSL.crypto.load_certificate(OpenSSL.crypto.FILETYPE_PEM, raw)
try:
privkey = OpenSSL.crypto.load_privatekey(OpenSSL.crypto.FILETYPE_PEM, raw)
except Exception:
privkey = None
- self.add_cert(SSLCert(cert), privkey, commonname)
+ self.add_cert(SSLCert(cert), privkey, spec)
def add_cert(self, cert, privkey, *names):
"""
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.
"""
- self.certs.add(cert.cn, (cert, privkey))
+ if cert.cn:
+ self.certs.add(cert.cn, (cert, privkey))
for i in cert.altnames:
self.certs.add(i, (cert, privkey))
for i in names: