Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PowerDNS provider #92

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ A [Rancher](http://rancher.com/rancher/) service that obtains free SSL/TLS certi
* `Gandi`
* `NS1`
* `Ovh`
* `PowerDNS`
* `Vultr`

* If using the HTTP challenge, a reverse proxy that routes `example.com/.well-known/acme-challenge` to `rancher-letsencrypt`.
Expand Down
2 changes: 2 additions & 0 deletions context.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ func (c *Context) InitContext() {
OvhApplicationKey: getEnvOption("OVH_APPLICATION_KEY", false),
OvhApplicationSecret: getEnvOption("OVH_APPLICATION_SECRET", false),
OvhConsumerKey: getEnvOption("OVH_CONSUMER_KEY", false),
PowerDNSUrl: getEnvOption("PDNS_URL", false),
PowerDNSKey: getEnvOption("PDNS_KEY", false),
GandiApiKey: getEnvOption("GANDI_API_KEY", false),
NS1ApiKey: getEnvOption("NS1_API_KEY", false),
}
Expand Down
29 changes: 29 additions & 0 deletions letsencrypt/providers.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package letsencrypt
import (
"fmt"
"os"
"net/url"

lego "github.com/xenolf/lego/acme"
"github.com/xenolf/lego/providers/dns/auroradns"
Expand All @@ -14,6 +15,7 @@ import (
"github.com/xenolf/lego/providers/dns/gandi"
"github.com/xenolf/lego/providers/dns/ns1"
"github.com/xenolf/lego/providers/dns/ovh"
"github.com/xenolf/lego/providers/dns/pdns"
"github.com/xenolf/lego/providers/dns/route53"
"github.com/xenolf/lego/providers/dns/vultr"
)
Expand Down Expand Up @@ -66,6 +68,10 @@ type ProviderOpts struct {
OvhApplicationSecret string
OvhConsumerKey string

// PowerDNS credentials
PowerDNSUrl string
PowerDNSKey string

// Vultr credentials
VultrApiKey string
}
Expand All @@ -82,6 +88,7 @@ const (
GANDI = Provider("Gandi")
NS1 = Provider("NS1")
OVH = Provider("Ovh")
PDNS = Provider("PowerDNS")
ROUTE53 = Provider("Route53")
VULTR = Provider("Vultr")
HTTP = Provider("HTTP")
Expand All @@ -102,6 +109,7 @@ var providerFactory = map[Provider]ProviderFactory{
GANDI: ProviderFactory{makeGandiProvider, lego.DNS01},
NS1: ProviderFactory{makeNS1Provider, lego.DNS01},
OVH: ProviderFactory{makeOvhProvider, lego.DNS01},
PDNS: ProviderFactory{makePdnsProvider, lego.DNS01},
ROUTE53: ProviderFactory{makeRoute53Provider, lego.DNS01},
VULTR: ProviderFactory{makeVultrProvider, lego.DNS01},
HTTP: ProviderFactory{makeHTTPProvider, lego.HTTP01},
Expand Down Expand Up @@ -262,6 +270,27 @@ func makeOvhProvider(opts ProviderOpts) (lego.ChallengeProvider, error) {
return provider, nil
}

// returns a preconfigured PowerDNS lego.ChallengeProvider
func makePdnsProvider(opts ProviderOpts) (lego.ChallengeProvider, error) {
if len(opts.PowerDNSUrl) == 0 {
return nil, fmt.Errorf("PowerDNS Url is not set")
}
if len(opts.PowerDNSKey) == 0 {
return nil, fmt.Errorf("PowerDNS API key is not set")
}

parsedUrl, err := url.Parse(opts.PowerDNSUrl)
if err != nil {
return nil, err
}

provider, err := pdns.NewDNSProviderCredentials(parsedUrl, opts.PowerDNSKey)
if err != nil {
return nil, err
}
return provider, nil
}

// returns a preconfigured Gandi lego.ChallengeProvider
func makeGandiProvider(opts ProviderOpts) (lego.ChallengeProvider, error) {
if len(opts.GandiApiKey) == 0 {
Expand Down