diff options
author | Jakub Warmuz <jakub@warmuz.org> | 2015-07-05 16:11:33 +0300 |
---|---|---|
committer | Jakub Warmuz <jakub@warmuz.org> | 2015-07-05 23:36:20 +0300 |
commit | e0293d81f3263ab958d041374c19634b335b35eb (patch) | |
tree | 269ad1dc86099cbc8f8f8ca1b00636193f192375 /examples | |
parent | 4407210e0114bcacb75567abb71dce27f908c96f (diff) |
acme: drop PyCrypto and use cryptography instead.
- Use cryptography in acme.jose.jwa/jwk.
- Change Crypto.Random to os.urandom,
c.f. https://cryptography.io/en/latest/random-numbers/?highlight=urandom
Diffstat (limited to 'examples')
-rw-r--r-- | examples/acme_client.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/examples/acme_client.py b/examples/acme_client.py index 09ff2bfc3..e67759583 100644 --- a/examples/acme_client.py +++ b/examples/acme_client.py @@ -3,7 +3,8 @@ import logging import os import pkg_resources -import Crypto.PublicKey.RSA +from cryptography.hazmat.backends import default_backend +from cryptography.hazmat.primitives.asymmetric import rsa import M2Crypto from acme import client @@ -18,8 +19,11 @@ NEW_REG_URL = 'https://www.letsencrypt-demo.org/acme/new-reg' BITS = 2048 # minimum for Boulder DOMAIN = 'example1.com' # example.com is ignored by Boulder -key = jose.JWKRSA.load( - Crypto.PublicKey.RSA.generate(BITS).exportKey(format="PEM")) +# generate_private_key requires cryptography>=0.5 +key = jose.JWKRSA(key=jose.ComparableRSAKey(rsa.generate_private_key( + public_exponent=65537, + key_size=2048, + backend=default_backend()))) acme = client.Client(NEW_REG_URL, key) regr = acme.register(contact=()) |