From 61bde090f4518d059d57ac71c968d402fbdbe88c Mon Sep 17 00:00:00 2001 From: Chandler Newman Date: Mon, 10 Jul 2023 22:19:15 +0100 Subject: [PATCH] Document AcquireCertificate --- website/config.toml | 5 +++++ website/content/docs/go/index.md | 31 +++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/website/config.toml b/website/config.toml index dad797e..c9a61ec 100644 --- a/website/config.toml +++ b/website/config.toml @@ -24,6 +24,11 @@ name = "Docs" url = "/docs/start" weight = 2 +[[menu.main]] +name = "GitHub" +url = "https://github.com/csnewman/dyndirect" +weight = 3 + [params] homepage_button_link = '/docs/start' homepage_button_text = 'Read The Docs' diff --git a/website/content/docs/go/index.md b/website/content/docs/go/index.md index 15ef53a..c186fc1 100644 --- a/website/content/docs/go/index.md +++ b/website/content/docs/go/index.md @@ -76,3 +76,34 @@ if err != nil { The challenge token will expire after some period of time. You should not rely on this value being available for any extended period. + +#### Automatically acquire certificate + +Instead of calling `SetSubdomainACMEChallenge` directly, you can use the `AcquireCertificate` helper to simplify the +process: + +```go +res, err := c.AcquireCertificate(ctx, dsdm.AcquireCertificateRequest{ + ID: r.Id, + Domain: r.Domain, + Token: r.Token, + Provider: dsdm.ProviderZeroSSL, + KeyType: certcrypto.RSA2048, + Timeout: 60 * time.Second, + SilenceLog: true, +}) +if err != nil { + // ... +} + +log.Info("Domain ", res.Domain) +log.Info("CertURL ", res.CertURL) +log.Info("CertStableURL ", res.CertStableURL) +log.Info("PrivateKey ", len(res.PrivateKey)) +log.Info("Certificate ", len(res.Certificate)) +log.Info("IssuerCertificate ", len(res.IssuerCertificate)) +log.Info("CSR ", len(res.CSR)) +``` + +`AcquireCertificate` implies acceptance of the TOS of the respective provider. Some providers may apply rate limits, +such as by IP.