diff --git a/cli.go b/cli.go index c07cf716..4e1d94b3 100644 --- a/cli.go +++ b/cli.go @@ -108,6 +108,19 @@ func main() { Name: "tls", Usage: "Set the port and interface to use for TLS based challenges to listen on. Supported: interface:port or :port", }, + cli.StringFlag{ + Name: "dns", + Usage: "Enable the DNS challenge for solving using a provider." + + "\n\tCredentials for providers have to be passed through environment variables." + + "\n\tFor a more detailed explanation of the parameters, please see the online docs." + + "\n\tValid providers:" + + "\n\tcloudflare: CLOUDFLARE_EMAIL, CLOUDFLARE_API_KEY" + + "\n\tdigitalocean: DO_AUTH_TOKEN" + + "\n\tdnsimple: DNSIMPLE_EMAIL, DNSIMPLE_API_KEY" + + "\n\troute53: AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_REGION_NAME" + + "\n\trfc2136: RFC2136_TSIG_KEY, RFC2136_TSIG_SECRET, RFC2136_NAMESERVER, RFC2136_ZONE" + + "\n\tmanual: none", + }, } app.Run(os.Args) diff --git a/cli_handlers.go b/cli_handlers.go index 613cd6e8..2b5b3fc0 100644 --- a/cli_handlers.go +++ b/cli_handlers.go @@ -51,6 +51,39 @@ func setup(c *cli.Context) (*Configuration, *Account, *acme.Client) { client.SetTLSAddress(c.GlobalString("tls")) } + if c.GlobalIsSet("dns") { + var err error + var provider acme.ChallengeProvider + switch c.GlobalString("dns") { + case "cloudflare": + provider, err = acme.NewDNSProviderCloudFlare("", "") + case "digitalocean": + authToken := os.Getenv("DO_AUTH_TOKEN") + + provider, err = acme.NewDNSProviderDigitalOcean(authToken) + case "dnsimple": + provider, err = acme.NewDNSProviderDNSimple("", "") + case "route53": + awsRegion := os.Getenv("AWS_REGION") + provider, err = acme.NewDNSProviderRoute53("", "", awsRegion) + case "rfc2136": + nameserver := os.Getenv("RFC2136_NAMESERVER") + zone := os.Getenv("RFC2136_ZONE") + tsigKey := os.Getenv("RFC2136_TSIG_KEY") + tsigSecret := os.Getenv("RFC2136_TSIG_SECRET") + + provider, err = acme.NewDNSProviderRFC2136(nameserver, zone, tsigKey, tsigSecret) + case "manual": + provider, err = acme.NewDNSProviderManual() + } + + if err != nil { + logger().Fatal(err) + } + + client.SetChallengeProvider(acme.DNS01, provider) + } + return conf, acc, client }