File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed
Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ extract the public or private keys from a x509 certificate in PEM format.
99
1010.. code-block :: python
1111
12+ # Python 2
1213 from cryptography.x509 import load_pem_x509_certificate
1314 from cryptography.hazmat.backends import default_backend
1415
@@ -17,9 +18,16 @@ extract the public or private keys from a x509 certificate in PEM format.
1718 public_key = cert_obj.public_key()
1819 private_key = cert_obj.private_key()
1920
20- .. note :: These instructions are for Python 2.
21- For Python 3, call ``encode() `` on ``cert_str `` to convert it
22- into bytes before calling ``load_pem_x509_certificate ``.
21+ .. code-block :: python
22+
23+ # Python 3
24+ from cryptography.x509 import load_pem_x509_certificate
25+ from cryptography.hazmat.backends import default_backend
26+
27+ cert_str = " -----BEGIN CERTIFICATE-----MIIDETCCAfm..." .encode()
28+ cert_obj = load_pem_x509_certificate(cert_str, default_backend())
29+ public_key = cert_obj.public_key()
30+ private_key = cert_obj.private_key()
2331
2432
2533 I'm using Google App Engine and can't install `cryptography `, what can I do?
You can’t perform that action at this time.
0 commit comments