문제

I am trying to understand about openssl and certificates and also Python.

So I have this .cert.p12 file. I would like to convert it to .pem format.

I use

openssl -in input.cert.p12 -out output.pem -nodes

This creates the pem file.

How would I do the same process in Python? Take in a p12 file and covert it to a pem format?

도움이 되었습니까?

해결책

Try using an OpenSSL for Python library like "pyOpenSSL"

https://pyopenssl.org/en/stable/api/crypto.html#pkcs12-objects

from OpenSSL import crypto
p12 = crypto.load_pkcs12(file("push.p12", 'rb').read(), [password])

# PEM formatted private key
print crypto.dump_privatekey(crypto.FILETYPE_PEM, p12.get_privatekey())

# PEM formatted certificate
print crypto.dump_certificate(crypto.FILETYPE_PEM, p12.get_certificate())

from here.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top