manivarma indukuri
manivarma indukuri

Reputation: 85

Problem while reading public key from .pem certificate into a variable in Python

I wanted to extract Public key from .pem certificate using cryptography library in Python. But I am facing problem. Here is the code :

from cryptography import x509
from cryptography.hazmat.backends import default_backend
from cryptography.x509.oid import NameOID
pem_cert=open("/home/lab14/aes/fd.pem","rb").read()
cert = x509.load_pem_x509_certificate(pem_cert, default_backend())
pub_key = cert.public_key()
print(pub_key)

This is the output I am getting :

<cryptography.hazmat.backends.openssl.rsa._RSAPublicKey object at 0x7f266caa36d8>

Please help me.

Upvotes: 0

Views: 1637

Answers (1)

Deepstop
Deepstop

Reputation: 3817

That is not an error. It is the representation of the RSAPublicKey object. So your code works, now you need to do something with the object. Check the documentation on the available properties and methods that the object provides.

Upvotes: 2

Related Questions