diff options
author | Mark Adams <mark@markadams.me> | 2015-03-15 16:25:02 -0500 |
---|---|---|
committer | Mark Adams <mark@markadams.me> | 2015-03-15 16:25:02 -0500 |
commit | 57c2201e946268743556855dce61f08d2cedfa4a (patch) | |
tree | fb2472726a9e20b8f52c0d89ae205206a39e64a7 | |
parent | 035057fd800c8739ba04544da417f512010c14b9 (diff) | |
download | pyjwt-57c2201e946268743556855dce61f08d2cedfa4a.tar.gz |
Resolved #93 by adding a section the README detailing how to extract public / private keys from an x509 certificate.
-rw-r--r-- | README.md | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -247,6 +247,22 @@ decoded = jwt.decode(token, 'secret', audience='urn:foo') If the audience claim is incorrect, `jwt.InvalidAudienceError` will be raised. +## Frequently Asked Questions + +**How can I extract a public / private key from a x509 certificate?** + +The `load_pem_x509_certificate()` function from `cryptography` can be used to +extract the public or private keys from a x509 certificate in PEM format. + +```python +from cryptography.x509 import load_pem_x509_certificate +from cryptography.hazmat.backends import default_backend + +cert_str = "-----BEGIN CERTIFICATE-----MIIDETCCAfm..." +cert_obj = load_pem_x509_certificate(cert_str, default_backend()) +public_key = cert_obj.public_key() +private_key = cert_obj.private_key() +``` ## License |