Client¶
ACME client API.
-
class
acme.client.
ClientV2
(directory: acme.messages.Directory, net: acme.client.ClientNetwork)[source]¶ ACME client for a v2 API.
- Variables
directory (messages.Directory) –
net (ClientNetwork) – Client network.
-
new_account
(new_account: acme.messages.NewRegistration) → acme.messages.RegistrationResource[source]¶ Register.
- Parameters
new_account (NewRegistration) –
- Raises
ConflictError – in case the account already exists
- Returns
Registration Resource.
- Return type
-
query_registration
(regr: acme.messages.RegistrationResource) → acme.messages.RegistrationResource[source]¶ Query server about registration.
- Parameters
regr (messages.RegistrationResource) – Existing Registration Resource.
-
update_registration
(regr: acme.messages.RegistrationResource, update: Optional[acme.messages.Registration] = None) → acme.messages.RegistrationResource[source]¶ Update registration.
- Parameters
regr (messages.RegistrationResource) – Registration Resource.
update (messages.Registration) – Updated body of the resource. If not provided, body will be taken from
regr
.
- Returns
Updated Registration Resource.
- Return type
-
new_order
(csr_pem: bytes) → acme.messages.OrderResource[source]¶ Request a new Order object from the server.
- Parameters
csr_pem (bytes) – A CSR in PEM format.
- Returns
The newly created order.
- Return type
-
poll
(authzr: acme.messages.AuthorizationResource) → Tuple[acme.messages.AuthorizationResource, requests.models.Response][source]¶ Poll Authorization Resource for status.
- Parameters
authzr (
AuthorizationResource
) – Authorization Resource- Returns
Updated Authorization Resource and HTTP response.
- Return type
(
AuthorizationResource
,requests.Response
)
-
poll_and_finalize
(orderr: acme.messages.OrderResource, deadline: Optional[datetime.datetime] = None) → acme.messages.OrderResource[source]¶ Poll authorizations and finalize the order.
If no deadline is provided, this method will timeout after 90 seconds.
- Parameters
orderr (messages.OrderResource) – order to finalize
deadline (datetime.datetime) – when to stop polling and timeout
- Returns
finalized order
- Return type
Poll Order Resource for status.
-
finalize_order
(orderr: acme.messages.OrderResource, deadline: datetime.datetime, fetch_alternative_chains: bool = False) → acme.messages.OrderResource[source]¶ Finalize an order and obtain a certificate.
- Parameters
orderr (messages.OrderResource) – order to finalize
deadline (datetime.datetime) – when to stop polling and timeout
fetch_alternative_chains (bool) – whether to also fetch alternative certificate chains
- Returns
finalized order
- Return type
-
revoke
(cert: josepy.util.ComparableX509, rsn: int) → None[source]¶ Revoke certificate.
- Parameters
cert (ComparableX509) –
OpenSSL.crypto.X509
wrapped inComparableX509
rsn (int) – Reason code for certificate revocation.
- Raises
ClientError – If revocation is unsuccessful.
-
external_account_required
() → bool[source]¶ Checks if ACME server requires External Account Binding authentication.
-
classmethod
get_directory
(url: str, net: acme.client.ClientNetwork) → acme.messages.Directory[source]¶ Retrieves the ACME directory (RFC 8555 section 7.1.1) from the ACME server. :param str url: the URL where the ACME directory is available :param ClientNetwork net: the ClientNetwork to use to make the request
- Returns
the ACME directory object
- Return type
-
deactivate_registration
(regr: acme.messages.RegistrationResource) → acme.messages.RegistrationResource[source]¶ Deactivate registration.
- Parameters
regr (messages.RegistrationResource) – The Registration Resource to be deactivated.
- Returns
The Registration resource that was deactivated.
- Return type
Deactivate authorization.
- Parameters
authzr (messages.AuthorizationResource) – The Authorization resource to be deactivated.
- Returns
The Authorization resource that was deactivated.
- Return type
-
answer_challenge
(challb: acme.messages.ChallengeBody, response: acme.challenges.ChallengeResponse) → acme.messages.ChallengeResource[source]¶ Answer challenge.
- Parameters
challb (
ChallengeBody
) – Challenge Resource body.response (
challenges.ChallengeResponse
) – Corresponding Challenge response
- Returns
Challenge Resource with updated body.
- Return type
- Raises
-
classmethod
retry_after
(response: requests.models.Response, default: int) → datetime.datetime[source]¶ Compute next
poll
time based on responseRetry-After
header.Handles integers and various datestring formats per https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.37
-
class
acme.client.
ClientNetwork
(key: josepy.jwk.JWK, account: Optional[acme.messages.RegistrationResource] = None, alg: josepy.jwa.JWASignature = RS256, verify_ssl: bool = True, user_agent: str = 'acme-python', timeout: int = 45)[source]¶ Wrapper around requests that signs POSTs for authentication.
Also adds user agent, and handles Content-Type.
-
REPLAY_NONCE_HEADER
= 'Replay-Nonce'¶ Initialize.
- Parameters
key (josepy.JWK) – Account private key
account (messages.RegistrationResource) – Account object. Required if you are planning to use .post() for anything other than creating a new account; may be set later after registering.
alg (josepy.JWASignature) – Algorithm to use in signing JWS.
verify_ssl (bool) – Whether to verify certificates on SSL connections.
user_agent (str) – String to send as User-Agent header.
timeout (int) – Timeout for requests.
-
head
(*args: Any, **kwargs: Any) → requests.models.Response[source]¶ Send HEAD request without checking the response.
Note, that
_check_response
is not called, as it is expected that status code other than successfully 2xx will be returned, or messages2.Error will be raised by the server.
-