methodTsmAcmeClient.ObtainCertificate
function ObtainCertificate: string; overload;
THE single call for requesting an HTTPS server certificate from Let's Encrypt in managed mode. Set the properties first - AccountKey, DirectoryUrl, TermsOfServiceAgreed, (Contact), CertificateKey, Domains, TLSServer, PfxFileName
- then call this once. It runs the whole lifecycle: register/adopt the account, place the order, answer tls-alpn-01 on TLSServer with CertificateKey, finalize with a CSR over CertificateKey, download the chain, install it into TLSServer (ReplaceTLSServerCertificate) and persist a PKCS#12 at PfxFileName. Returns the issued PEM chain (leaf first). Raises eAcmeError on any ACME problem. The parameterless overload uses the Domains and CertificateKey properties; the overload lets one client issue for several domain sets / keys in turn (the renewal manager uses it).
REQUIRES A SERVER - TLSServer *or* AsyncTLSServer, whichever kind this deployment runs. They are mutually exclusive and AlpnTarget reports whichever is set, so nothing here cares which.
AND YOU RARELY WANT TO CALL IT DIRECTLY. It BLOCKS for the whole exchange - account, order, challenge, validation polling, finalize, download - which is seconds to minutes, so it cannot run on a UI thread or on the thread a service is started from. Set TsmAcmeRenewalManager.ManageClientCertificate instead and let the manager's own worker do this on its first pass; that also keeps the certificate renewed afterwards, which one call here does not.
function ObtainCertificate(aDomains: TStrings; aCertKey: TComponent): string; overload;
Delegates to
ObtainCertificate, forwarding fDomains and fCertKey, and returns its result.
function ObtainCertificate(aDomains: TStrings; aCertKey: TComponent; const aReplacesLeafDer: tBytes): string; overload;
As above, but naming the certificate this order REPLACES: aReplacesLeafDer is the DER of the leaf being renewed, passed to newOrder as the RFC 9773 "replaces" field so an ARI-aware CA can correlate the renewal with what it is superseding. Use this overload for every RENEWAL; the two-argument one, which names no predecessor, is for a first issuance. Passing an empty array is identical to the two-argument overload.