Commit graph

6 commits

Author SHA1 Message Date
Brad Warren
fde359f4da
fixup http01_example.py (#10285)
it looks like https://github.com/certbot/certbot/pull/10098 introduced a
couple bugs into this file:

1.
[RSAPrivateKeys](https://cryptography.io/en/latest/hazmat/primitives/asymmetric/rsa/#cryptography.hazmat.primitives.asymmetric.rsa.RSAPrivateKey)
don't have a `public_bytes` method
2. `cryptography.x509` wasn't imported and
[load_pem_x509_certificate](https://cryptography.io/en/latest/x509/reference/#cryptography.x509.load_pem_x509_certificate)
takes bytes, not a string

i think avoiding this is unfortunately difficult as this file has no
tests, but it was useful for me just now when testing
https://github.com/certbot/certbot/pull/10283 so i wanted to fix it up

i also changed the script to initially create the account without an
email address as the fake@example.com email causes registration with
LE's staging server to fail early in execution

with the changes in this PR changes, if you:

1. change the value of
[DOMAIN](0075104805/acme/examples/http01_example.py (L57))
to a domain pointing at your machine
2. as root, activate your certbot dev environment, and run `python
acme/examples/http01_example.py `

it will fail late in the script with:
```
Traceback (most recent call last):
  File "/home/brad/certbot/acme/examples/http01_example.py", line 237, in <module>
    example_http()
    ~~~~~~~~~~~~^^
  File "/home/brad/certbot/acme/examples/http01_example.py", line 223, in example_http
    regr = client_acme.update_registration(
        regr.update(
    ...<3 lines>...
        )
    )
  File "/home/brad/certbot/acme/src/acme/client.py", line 101, in update_registration
    updated_regr = self._send_recv_regr(regr, body=body)
  File "/home/brad/certbot/acme/src/acme/client.py", line 373, in _send_recv_regr
    response = self._post(regr.uri, body)
  File "/home/brad/certbot/acme/src/acme/client.py", line 392, in _post
    return self.net.post(*args, **kwargs)
           ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/home/brad/certbot/acme/src/acme/client.py", line 766, in post
    return self._post_once(*args, **kwargs)
           ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/home/brad/certbot/acme/src/acme/client.py", line 781, in _post_once
    response = self._check_response(response, content_type=content_type)
  File "/home/brad/certbot/acme/src/acme/client.py", line 630, in _check_response
    raise messages.Error.from_json(jobj)
acme.messages.Error: urn:ietf:params:acme:error:invalidContact :: The provided contact URI was invalid :: Unable to update account :: invalid contact: contact email has forbidden domain "example.org"
```
if you also change [this email
variable](0075104805/acme/examples/http01_example.py (L223))
to a valid email address, the script will run successfully
2025-05-08 15:43:37 -07:00
Jonathan Vanasco
dd876a40ed
Feature acme cryptography 2 (#10245)
redoing https://github.com/certbot/certbot/pull/10174 but lots of
mergecommits and ff wanted; so test in a clean environment
2025-04-02 10:53:47 -07:00
Alex Gaynor
724be8848a
Convert http01_example.py to use cryptography's APIs (#10098)
Co-authored-by: ohemorange <ebportnoy@gmail.com>
2024-12-18 23:54:44 +00:00
alexzorin
804ca32314
acme: remove Client and BackwardsCompatibleClientV2 (#9356)
* acme: remove Client and BackwardsCompatibleClientV2

* remove ClientTestBase and some unused variables

* add ClientV2.get_directory

* tweak ToS callback code

* acme: update example to use ClientV2.get_directory

* simplify ToS callback further into one step

* further removal of acmev1-related code

- remove acme.client.ClientBase
- remove acme.mixins.VersionedLEACMEMixin
- remove acme.client.DER_CONTENT_TYPE
- remove various ACMEv1 special cases
- remove acme.messages.ChallengeResources.combinations

* remove .mixins.ResourceMixin, fields.resource, fields.Resource
and resource field from various .message classes.

* simplify acme.messages.Directory:

- remove Directory.register
- remove HasResourceType and GenericHasResourceType
- remove ability to look up Directory resources by anything other
  than the exact field name in RFC8555 (section 9.7.5)

* remove acme.messages.OLD_ERROR_PREFIX and support the old prefix

* remove acme.mixins

* reorder imports

* add comment to Directory about resource lookups

* s/new-cert/newOrder/

* get rid of `resource` sillyness in tests

* remove acmev1 terms-of-service support from directory
2022-09-06 14:36:55 -07:00
Adrien Ferrand
e048da1e38 Reorganize imports (#7616)
* Isort execution

* Fix pylint, adapt coverage

* New isort

* Fix magic_typing lint

* Second round

* Fix pylint

* Third round. Store isort configuration

* Fix latest mistakes

* Other fixes

* Add newline

* Fix lint errors
2019-12-09 15:50:20 -05:00
Julie R
401045be89 Add acme library usage example (http-01) (#5494)
* Add acme library usage example

Create, edit and deactivate account.
Setup and perform http-01 challenge.
Issue, renew and revoke certificate.

* Adapt example to ACME-v2 and exclude data persistence

The code to persist/load data would length this example and distract from what is actually important.

* Fix domain names and e-mail addresses

* Remove unnecessary license header

This usage example is under the license for the acme package.

* Remove logging information

The code will be mostly read by developers, so simplify the logging info into comments.

* Revert abstraction of simple methods

All methods that are used only once in this example were expanded into the main code in order to make the process more explicit.

* Fix missing URL suffix

* Improve aesthetics and reorganize workflow

Also make words capitalization consistent and improve comments.
No complaints from pep8.
2019-02-22 18:02:43 -08:00