summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Binetti <dbinetti@gmail.com>2017-03-28 13:56:44 -0700
committerDavid Binetti <dbinetti@gmail.com>2017-03-28 13:56:44 -0700
commit06ca56a299eb0fde56cbe6bf0f4bae18f6b4f4c1 (patch)
treede2fc1273e313d753c9db6ee679ae435917d2648
parent3cb92d5b1a2a8f19203c1161f1989ba86262fddb (diff)
downloadpyjwt-06ca56a299eb0fde56cbe6bf0f4bae18f6b4f4c1.tar.gz
Be specific for Python2 and Python3
-rw-r--r--docs/faq.rst14
1 files changed, 11 insertions, 3 deletions
diff --git a/docs/faq.rst b/docs/faq.rst
index 336640c..a5eb139 100644
--- a/docs/faq.rst
+++ b/docs/faq.rst
@@ -9,6 +9,7 @@ extract the public or private keys from a x509 certificate in PEM format.
.. code-block:: python
+ # Python 2
from cryptography.x509 import load_pem_x509_certificate
from cryptography.hazmat.backends import default_backend
@@ -17,9 +18,16 @@ extract the public or private keys from a x509 certificate in PEM format.
public_key = cert_obj.public_key()
private_key = cert_obj.private_key()
-.. note:: These instructions are for Python 2.
- For Python 3, call ``encode()`` on ``cert_str`` to convert it
- into bytes before calling ``load_pem_x509_certificate``.
+.. code-block:: python
+
+ # Python 3
+ from cryptography.x509 import load_pem_x509_certificate
+ from cryptography.hazmat.backends import default_backend
+
+ cert_str = "-----BEGIN CERTIFICATE-----MIIDETCCAfm...".encode()
+ cert_obj = load_pem_x509_certificate(cert_str, default_backend())
+ public_key = cert_obj.public_key()
+ private_key = cert_obj.private_key()
I'm using Google App Engine and can't install `cryptography`, what can I do?