From bd9d0bf6b1bd01ee989a729278e64b73de13ccfc Mon Sep 17 00:00:00 2001 From: Oliver Graff Date: Mon, 12 Jun 2017 00:44:29 -0700 Subject: Remove private key from PKCS12 file Fixes #2349 --- mitmproxy/certs.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mitmproxy/certs.py b/mitmproxy/certs.py index 618b34de..0e441efe 100644 --- a/mitmproxy/certs.py +++ b/mitmproxy/certs.py @@ -264,6 +264,12 @@ class CertStore: # Dump the certificate in PKCS12 format for Windows devices with open(os.path.join(path, basename + "-ca-cert.p12"), "wb") as f: + p12 = OpenSSL.crypto.PKCS12() + p12.set_certificate(ca) + f.write(p12.export()) + + # Dump the certificate and key in a PKCS12 format for Windows devices + with open(os.path.join(path, basename + "-ca.p12"), "wb") as f: p12 = OpenSSL.crypto.PKCS12() p12.set_certificate(ca) p12.set_privatekey(key) -- cgit v1.2.3