Skip to content
FutureBlitz

    Install

    Import std.net.acme_client

    AcmeClient

    std.net.acme_client

    class

    Public Class AcmeClient

    A client of one ACME CA, with an account key, an ECDSA P-256 private key, which signs each request, and Http, which it sends them with, which can trust a test CA's roots.

    Examples

    Local tokens = AcmeTokens()
    // A server answers /.well-known/acme-challenge/<token> on port 80 with tokens.Answer(path).
    Local directory = "https://acme-v02.api.letsencrypt.org/directory"
    Local client = Try AcmeClient.InFolder(directory, Path("acme"))
    Local key = Key(KeyKind.ECDSA_P256, True, EcdsaP256.NewPrivateKey())
    Local chain = Try client.ObtainAsync(["example.com"], key, tokens).Wait()
    Try File.WriteText(Path("fullchain.pem"), chain)

    std/net/acme_client.fb, line 87

    • @PanicsAtCaller Public New(directory: String, accountKey: Key) constructor #

      A client of the CA whose directory is at directory. Panics unless accountKey is an ECDSA P-256 private key, of 32 bytes that are one.

    • @PanicsAtCaller Public Static Method InFolder(directory: String, folder: Path): AcmeClient Throws IOError, ParseError static method #

      A client of the CA whose directory is at directory, with the account key folder keeps as account.pem, or a new ECDSA P-256 key, which it writes there atomically, making the folder, for the runs after; automatic HTTPS's ListenAutoAsync keeps its certificate in the same folder. Throws an IOError when the folder can't be read or written, or a ParseError when its account.pem isn't a key's PEM. Panics as New does for a key it keeps that isn't an ECDSA P-256 private key.

    • Public Property Http: HttpClient property #

      What its requests go through.

    • Public Property Account: String? property #

      The account's URL, once Register or Obtain has made it or found it.

    • Public Async Method RegisterAsync(contact: String[] = []): String Throws NetError, TimeoutError method #

      Makes the account, agreeing to the CA's terms of service, with contact, mailto: URLs, or finds the one the key has, and gives its URL.

    • @PanicsAtCaller Public Async Method ObtainAsync(names: String[], certificateKey: Key, tokens: AcmeTokens): String Throws NetError, TimeoutError method #

      A certificate for names, DNS names, of certificateKey, an ECDSA P-256 private key, as PEM, its chain after it: it orders one, publishes each name's HTTP-01 key authorization through tokens while the CA checks it, finalizes the order with a CSR, and gives what the CA issued. It registers first, with no contact, when Register hasn't. Panics as Acme.CertificateRequest does for the key and names.

    Report an issue with this page or with FutureBlitz on GitHub.