Created
June 12, 2017 04:40
-
-
Save sakurai-youhei/a0291e1e7f8130edaa0cf74661f97a62 to your computer and use it in GitHub Desktop.
Export private key from *.pfx file (PKCS12) into PEM format using pyOpenSSL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from OpenSSL import crypto | |
with open("path/to/cert.pfx", "rb") as pfx: | |
cert = crypto.load_pkcs12(pfx.read()) | |
pkey = cert.get_privatekey() | |
with open("path/to/pkey.pem", "wb") as pem: | |
pem.write(crypto.dump_privatekey(crypto.FILETYPE_PEM, pkey)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment