diff options
author | James Kasten <jdkasten@umich.edu> | 2015-04-02 01:14:20 +0300 |
---|---|---|
committer | James Kasten <jdkasten@umich.edu> | 2015-04-02 01:14:20 +0300 |
commit | e41acf72a0c5c0489af3a9238251fe389ce64857 (patch) | |
tree | 9251bb0e4f7c94c61758567759df29d111c709fd /examples | |
parent | d638221e553dbea80d5c6ce0ea46fcc6d7b9ac1b (diff) | |
parent | 7a4c7acdfb1afa534f310078ad1ffba4ecb60947 (diff) |
Merge pull request #325 from kuba/network2
Restified messages2 and network2
Diffstat (limited to 'examples')
-rw-r--r-- | examples/restified.py | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/examples/restified.py b/examples/restified.py new file mode 100644 index 000000000..651ecccd1 --- /dev/null +++ b/examples/restified.py @@ -0,0 +1,42 @@ +import logging +import os +import pkg_resources + +import M2Crypto + +from letsencrypt.acme import messages2 +from letsencrypt.acme import jose + +from letsencrypt.client import network2 + + +logger = logging.getLogger() +logger.setLevel(logging.DEBUG) + +NEW_REG_URL = 'https://www.letsencrypt-demo.org/acme/new-reg' + +key = jose.JWKRSA.load(pkg_resources.resource_string( + 'letsencrypt.acme.jose', os.path.join('testdata', 'rsa512_key.pem'))) +net = network2.Network(NEW_REG_URL, key) + +regr = net.register(contact=( + 'mailto:cert-admin@example.com', 'tel:+12025551212')) +logging.info('Auto-accepting TOS: %s', regr.terms_of_service) +net.update_registration(regr.update( + body=regr.body.update(agreement=regr.terms_of_service))) +logging.debug(regr) + +authzr = net.request_challenges( + identifier=messages2.Identifier( + typ=messages2.IDENTIFIER_FQDN, value='example1.com'), + regr=regr) +logging.debug(authzr) + +authzr, authzr_response = net.poll(authzr) + +csr = M2Crypto.X509.load_request_string(pkg_resources.resource_string( + 'letsencrypt.client.tests', os.path.join('testdata', 'csr.pem'))) +try: + net.request_issuance(csr, (authzr,)) +except messages2.Error as error: + print error.detail |