Skip to content

Commit 169c73c

Browse files
committed
Getting public cert from Certificate.
1 parent e45d4e8 commit 169c73c

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/cryptojwt/jwk/x509.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,20 @@ def import_public_key_from_pem_data(pem_data):
6262
return cert.public_key()
6363

6464

65+
def import_public_key_from_cert_file(filename):
66+
"""
67+
Read a public key from a certificate file.
68+
69+
:param filename: The name of the file
70+
:return: A public key instance
71+
"""
72+
with open(filename, "rb") as key_file:
73+
cert = x509.load_pem_x509_certificate(
74+
key_file.read(), backend=default_backend()
75+
)
76+
return cert.public_key()
77+
78+
6579
def der_cert(der_data):
6680
"""
6781
Load a DER encoded certificate

0 commit comments

Comments
 (0)