Python: How do I extract public key from a '.cert' file?

Python: How do I extract public key from a '.cert' file?

I have used openssl to generate a X.509 self-signed like so:

I have used openssl to generate a X.509 self-signed like so:

openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365

This generated two files: cert.pem and a key.pem files.

My cert.pem file contains the public key. How do I extract it using Python?

I am unable to use the OpenSSl library of python. I am able to use the cryptography library.

My current code:

cert = x509.load_pem_x509_certificate(pem_data, default_backend())
print(cert.public_key)


Angular 9 Tutorial: Learn to Build a CRUD Angular App Quickly

What's new in Bootstrap 5 and when Bootstrap 5 release date?

Brave, Chrome, Firefox, Opera or Edge: Which is Better and Faster?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

Top Python Development Companies | Hire Python Developers

After analyzing clients and market requirements, TopDevelopers has come up with the list of the best Python service providers. These top-rated Python developers are widely appreciated for their professionalism in handling diverse projects. When...

Python GUI Programming Projects using Tkinter and Python 3

Python GUI Programming Projects using Tkinter and Python 3

Guide to Python Programming Language

Guide to Python Programming Language