Client¶
lacme.client ¶
Async ACME v2 protocol client (RFC 8555).
Provides the :class:Client class which implements the full ACME order
lifecycle: account creation, order placement, challenge handling,
finalization, and certificate download.
Client ¶
Async ACME v2 client.
Usage::
async with Client(directory_url="...", account_key=key) as client:
cert = await client.issue(["example.com"])
auto_renew
async
¶
auto_renew(*, interval_hours: float = 12.0, days_before_expiry: int = 30, on_renewed: Callable[[CertBundle], Any] | None = None) -> asyncio.Task[None]
Start a background renewal task. Requires a store.
Returns the :class:asyncio.Task running the renewal loop.
Raises:
| Type | Description |
|---|---|
ValueError
|
If no store was provided to the client. |
check_rate_limits ¶
Check if issuing for domains would exceed rate limits.
Requires a rate_limit_tracker to be set on the client.
Raises:
| Type | Description |
|---|---|
ValueError
|
If no rate limit tracker is configured. |
create_account
async
¶
create_account(*, contact: list[str] | None = None, terms_of_service_agreed: bool = True, only_return_existing: bool = False, eab_kid: str | None = None, eab_hmac_key: str | None = None) -> Account
Create or find an existing ACME account.
Sets the internal account URL for subsequent requests.
For CAs requiring External Account Binding (e.g. ZeroSSL), pass
eab_kid and eab_hmac_key (base64url-encoded). These fall
back to the values provided at Client construction time.
create_authorization
async
¶
create_authorization(identifier_value: str, *, identifier_type: IdentifierType = IdentifierType.DNS) -> Authorization
Create a pre-authorization for an identifier (RFC 8555 §7.4.1).
Requires the server to support newAuthz (optional per RFC 8555).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
identifier_value
|
str
|
Domain name or IP address. |
required |
identifier_type
|
IdentifierType
|
Identifier type (default |
DNS
|
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the server does not expose a |
create_order
async
¶
create_order(domains: str | list[str], *, not_before: str | None = None, not_after: str | None = None) -> Order
Create a new certificate order.
download_certificate
async
¶
Download the certificate chain via POST-as-GET.
finalize_order
async
¶
Submit the CSR to finalize the order.
get_authorization
async
¶
Fetch an authorization via POST-as-GET.
get_authorizations
async
¶
Fetch all authorizations for an order.
Fetches are serialized to avoid nonce pool contention.
issue
async
¶
issue(domains: str | list[str], *, challenge_type: str = 'http-01', challenge_map: dict[str, tuple[str, ChallengeHandler]] | None = None) -> CertBundle
Issue a certificate for the given domain(s).
Orchestrates: account → order → authorize → finalize → download.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
domains
|
str | list[str]
|
Domain name(s) to include in the certificate. |
required |
challenge_type
|
str
|
Default challenge type for all domains. |
'http-01'
|
challenge_map
|
dict[str, tuple[str, ChallengeHandler]] | None
|
Per-domain overrides mapping
|
None
|
poll_authorization
async
¶
Poll an authorization until it reaches a terminal state.
poll_order
async
¶
Poll an order until it reaches a terminal state (valid or invalid).
respond_to_challenge
async
¶
Signal readiness for challenge validation (POST {} to challenge URL).
revoke
async
¶
Revoke a certificate using the account key (RFC 8555 §7.6).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cert_pem
|
bytes | str
|
PEM-encoded certificate to revoke. |
required |
reason
|
int | None
|
Optional revocation reason code
(see :class: |
None
|
revoke_with_cert_key
async
¶
revoke_with_cert_key(cert_pem: bytes | str, cert_key: EllipticCurvePrivateKey, *, reason: int | None = None) -> None
Revoke a certificate using its own key pair (RFC 8555 §7.6).
Does not require an ACME account. The JWS is signed with cert_key and uses a JWK header (not KID).
rollover_key
async
¶
Roll over the account key (RFC 8555 §7.3.5).
Replaces the current account key with new_key (generated if None).
On success the new key is stored if a store was provided.