diff options
author | Thomas Kriechbaumer <thomas@kriechbaumer.name> | 2017-02-26 12:47:10 +0100 |
---|---|---|
committer | Thomas Kriechbaumer <thomas@kriechbaumer.name> | 2017-02-26 20:54:04 +0100 |
commit | 6d228dfb9ffa4c12e3633b48b77b9c7d44a8f4ae (patch) | |
tree | 005949ce9c93f3ca7dd1e120832e9e72968a4b3f /mitmproxy/certs.py | |
parent | 9b6986ea87927115f1974e2c3a442b17e86e352c (diff) | |
download | mitmproxy-6d228dfb9ffa4c12e3633b48b77b9c7d44a8f4ae.tar.gz mitmproxy-6d228dfb9ffa4c12e3633b48b77b9c7d44a8f4ae.tar.bz2 mitmproxy-6d228dfb9ffa4c12e3633b48b77b9c7d44a8f4ae.zip |
certs: coverage++
Diffstat (limited to 'mitmproxy/certs.py')
-rw-r--r-- | mitmproxy/certs.py | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/mitmproxy/certs.py b/mitmproxy/certs.py index 4b939c80..7b5c833b 100644 --- a/mitmproxy/certs.py +++ b/mitmproxy/certs.py @@ -93,9 +93,9 @@ def dummy_cert(privkey, cacert, commonname, sans): try: ipaddress.ip_address(i.decode("ascii")) except ValueError: - ss.append(b"DNS: %s" % i) + ss.append(b"DNS:%s" % i) else: - ss.append(b"IP: %s" % i) + ss.append(b"IP:%s" % i) ss = b", ".join(ss) cert = OpenSSL.crypto.X509() @@ -356,14 +356,14 @@ class CertStore: class _GeneralName(univ.Choice): - # We are only interested in dNSNames. We use a default handler to ignore - # other types. - # TODO: We should also handle iPAddresses. + # We only care about dNSName and iPAddress componentType = namedtype.NamedTypes( namedtype.NamedType('dNSName', char.IA5String().subtype( implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2) - ) - ), + )), + namedtype.NamedType('iPAddress', univ.OctetString().subtype( + implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 7) + )), ) @@ -477,5 +477,9 @@ class SSLCert(serializable.Serializable): except PyAsn1Error: continue for i in dec[0]: - altnames.append(i[0].asOctets()) + if i[0] is None and isinstance(i[1], univ.OctetString) and not isinstance(i[1], char.IA5String): + e = b'.'.join([str(e).encode() for e in i[1].asNumbers()]) + else: + e = i[0].asOctets() + altnames.append(e) return altnames |