API Reference¶
- aioacme.LETS_ENCRYPT_STAGING_DIRECTORY = 'https://acme-staging-v02.api.letsencrypt.org/directory'¶
The Let’s Encrypt staging directory URL.
- aioacme.LETS_ENCRYPT_DIRECTORY = 'https://acme-v02.api.letsencrypt.org/directory'¶
The Let’s Encrypt directory URL.
- aioacme.ZEROSSL_DIRECTORY = 'https://acme.zerossl.com/v2/DV90'¶
ZeroSSL directory URL.
- class aioacme.Client(*, account_key: RSAPrivateKey | EllipticCurvePrivateKey | Ed25519PrivateKey, directory_url: str = LETS_ENCRYPT_STAGING_DIRECTORY, account_uri: str | None = None, external_account_binding: ExternalAccountBinding | None = None, ssl: SSLContext | bool = True)¶
Create new ACME client.
By using this library you agree to the terms of service of the ACME server you are using.
- Parameters:
account_key – private key for account.
directory_url – URL to get directory.
account_uri – optional account URI, if not provided, it would be fetched on first request.
ssl – SSL context.
- account_key: RSAPrivateKey | EllipticCurvePrivateKey | Ed25519PrivateKey¶
- external_account_binding: ExternalAccountBinding | None¶
- async update_account(*, contact: Sequence[str] | None = None, status: Literal[AccountStatus.deactivated] | None = None) Account¶
Update account info.
- Parameters:
contact – list of contacts.
status – new account status, accepts only
AccountStatus.deactivated.
- async new_order(identifiers: Sequence[Identifier], *, not_before: datetime | None = None, not_after: datetime | None = None) Order¶
Create new certificate order.
- Parameters:
identifiers – list of identifiers (domains or ips).
not_before – the requested value of the notBefore field in the certificate.
not_after – the requested value of the notAfter field in the certificate.
- async get_authorization(authorization_uri: str) Authorization¶
Get existing authorization.
- Parameters:
authorization_uri – authorization URI.
- get_dns_challenge_domain(domain: str) str¶
Generate domain for DNS challenge.
- Parameters:
domain – domain.
- get_dns_challenge_validation(token: str) str¶
Generate TXT record value for DNS challenge.
- Parameters:
token – challenge token.
- async answer_challenge(url: str) Challenge¶
Respond to the challenge.
https://datatracker.ietf.org/doc/html/rfc8555#section-7.5.1
- Parameters:
url – challenge url.
- async deactivate_authorization(uri: str) Authorization¶
Deactivate authorization.
https://datatracker.ietf.org/doc/html/rfc8555#section-7.5.2
- Parameters:
uri – authorization URI.
- async finalize_order(finalize: str, csr: CertificateSigningRequest) Order¶
Finalize the order by submitting the CSR to issue certificate.
- Parameters:
finalize – finalize uri.
csr – CSR.
- async get_certificate(certificate: str) bytes¶
Download ready certificate in PEM format.
- Parameters:
certificate – certificate URL.
- async revoke_certificate(certificate: Certificate, key: RSAPrivateKey | EllipticCurvePrivateKey | Ed25519PrivateKey | None = None, reason: RevocationReason = RevocationReason.unspecified) None¶
Revoke certificate.
https://datatracker.ietf.org/doc/html/rfc8555#section-7.6
- Parameters:
certificate – certificate.
key – private key, if you want to revoke certificate without account key.
reason – reason.
- async change_key(new_account_key: RSAPrivateKey | EllipticCurvePrivateKey | Ed25519PrivateKey) None¶
Change private key for current account. Further requests will be signed with this new key.
https://datatracker.ietf.org/doc/html/rfc8555#section-7.6
- Parameters:
new_account_key – new private key.
- async __aexit__(exc_type: type[BaseException] | None, exc: BaseException | None, tb: TracebackType | None) None¶
- class aioacme.AccountStatus¶
Bases:
EnumAccount status.
- valid = 'valid'¶
Account is active.
- deactivated = 'deactivated'¶
Client requested deactivation of the account.
- revoked = 'revoked'¶
Server revoked the account.
- class aioacme.Account¶
Account object.
- status: AccountStatus¶
- created_at: datetime, <CustomEncoder: serialize=None, deserialize=Some(Py(0x72c01de704c0))>] | None¶
- class aioacme.Identifier¶
Identifier object.
- type: IdentifierType¶
- class aioacme.Error¶
Error object.
- identifier: Identifier | None¶
- class aioacme.OrderStatus¶
Bases:
EnumOrder status.
- pending = 'pending'¶
The order is waiting for the client to satisfy authorizations challenges.
- ready = 'ready'¶
All authorizations have been satisfied, the order is ready to finalize.
- processing = 'processing'¶
The server is issuing the certificate.
- valid = 'valid'¶
The certificate has been issued.
- invalid = 'invalid'¶
The order has expired or one of its authorizations has failed.
- class aioacme.Order¶
Order object.
- identifiers: Sequence[Identifier]¶
An array of identifier objects that the order pertains to.
- authorizations: Sequence[str]¶
For pending orders, the authorizations that the client needs to complete before the requested certificate can be issued, including unexpired authorizations that the client has completed in the past for identifiers specified in the order. The authorizations required are dictated by server policy; there may not be a 1:1 relationship between the order identifiers and the authorizations required. For final orders (in the “valid” or “invalid” state), the authorizations that were completed. Each entry is a URL from which an authorization can be fetched.
- status: OrderStatus¶
The status of this order.
- expires: datetime | None¶
The timestamp after which the server will consider this order invalid. This field is REQUIRED for objects with “pending” or “valid” in the status field.
- class aioacme.ChallengeType¶
Bases:
EnumChallenge type.
- dns01 = 'dns-01'¶
- dnsaccount01 = 'dns-account-01'¶
- http01 = 'http-01'¶
- tlsalpn01 = 'tls-alpn-01'¶
- class aioacme.ChallengeStatus¶
Bases:
EnumChallenge status.
- pending = 'pending'¶
The challenge is waiting to be validated.
- processing = 'processing'¶
The challenge is in the process of being validated.
- valid = 'valid'¶
The challenge has been successfully validated.
- invalid = 'invalid'¶
The challenge has not been successfully validated.
- class aioacme.Challenge¶
Challenge object.
- type: ChallengeType¶
The type of challenge encoded in the object.
- status: ChallengeStatus¶
The status of this challenge.
- validated: datetime | None¶
The time at which the server validated this challenge, encoded in the format specified in [RFC3339]. This field is REQUIRED if the “status” field is “valid”.
- class aioacme.AuthorizationStatus¶
Bases:
EnumAuthorization status.
- pending = 'pending'¶
The authorization is waiting to be validated.
- valid = 'valid'¶
The authorization has been successfully validated.
- invalid = 'invalid'¶
The authorization has not been successfully validated.
- expired = 'expired'¶
The authorization has expired.
- deactivated = 'deactivated'¶
The client has deactivated the authorization.
- class aioacme.Authorization¶
Authorization object.
- identifier: Identifier¶
The identifier that the account is authorized to represent.
- status: AuthorizationStatus¶
The status of this authorization.
- expires: datetime | None¶
The timestamp after which the server will consider this authorization invalid, encoded in the format specified in [RFC3339]. This field is REQUIRED for objects with “valid” in the “status” field.
- challenges: Sequence[Challenge]¶
For pending authorizations, the challenges that the client can fulfill in order to prove possession of the identifier. For valid authorizations, the challenge that was validated. For invalid authorizations, the challenge that was attempted and failed. Each array entry is an object with parameters required to validate the challenge. A client should attempt to fulfill one of these challenges, and a server should consider any one of the challenges sufficient to make the authorization valid.
- class aioacme.RevocationReason¶
Bases:
EnumReason to revoke certificate.
- unspecified = 0¶
- key_compromise = 1¶
- ca_compromise = 2¶
- affiliation_changed = 3¶
- superseded = 4¶
- cessation_of_operation = 5¶
- certificate_hold = 6¶
- remove_from_crl = 8¶
- privilege_withdrawn = 9¶
- aa_compromise = 10¶
- class aioacme.ExternalAccountBinding¶
External Account Binding credentials.