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 Namecheap as a DNS provider #71

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
11 changes: 8 additions & 3 deletions Godeps/Godeps.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ A [Rancher](http://rancher.com/rancher/) service that obtains free SSL/TLS certi
* `DNSimple`
* `Dyn`
* `Gandi`
* `Namecheap`
* `NS1`
* `Ovh`
* `Vultr`
Expand Down
2 changes: 2 additions & 0 deletions context.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ func (c *Context) InitContext() {
OvhConsumerKey: getEnvOption("OVH_CONSUMER_KEY", false),
GandiApiKey: getEnvOption("GANDI_API_KEY", false),
NS1ApiKey: getEnvOption("NS1_API_KEY", false),
NamecheapApiUser: getEnvOption("NAMECHEAP_API_USER", false),
NamecheapApiKey: getEnvOption("NAMECHEAP_API_KEY", false),
}

c.Acme, err = letsencrypt.NewClient(emailParam, keyType, apiVersion, providerOpts)
Expand Down
24 changes: 24 additions & 0 deletions letsencrypt/providers.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/xenolf/lego/providers/dns/dnsimple"
"github.com/xenolf/lego/providers/dns/dyn"
"github.com/xenolf/lego/providers/dns/gandi"
"github.com/xenolf/lego/providers/dns/namecheap"
"github.com/xenolf/lego/providers/dns/ns1"
"github.com/xenolf/lego/providers/dns/ovh"
"github.com/xenolf/lego/providers/dns/route53"
Expand Down Expand Up @@ -58,6 +59,10 @@ type ProviderOpts struct {
// Gandi credentials
GandiApiKey string

// Namecheap credentials
NamecheapApiUser string
NamecheapApiKey string

// NS1 credentials
NS1ApiKey string

Expand All @@ -80,6 +85,7 @@ const (
DNSIMPLE = Provider("DNSimple")
DYN = Provider("Dyn")
GANDI = Provider("Gandi")
NAMECHEAP = Provider("Namecheap")
NS1 = Provider("NS1")
OVH = Provider("Ovh")
ROUTE53 = Provider("Route53")
Expand All @@ -100,6 +106,7 @@ var providerFactory = map[Provider]ProviderFactory{
DNSIMPLE: ProviderFactory{makeDNSimpleProvider, lego.DNS01},
DYN: ProviderFactory{makeDynProvider, lego.DNS01},
GANDI: ProviderFactory{makeGandiProvider, lego.DNS01},
NAMECHEAP: ProviderFactory{makeNamecheapProvider, lego.DNS01},
NS1: ProviderFactory{makeNS1Provider, lego.DNS01},
OVH: ProviderFactory{makeOvhProvider, lego.DNS01},
ROUTE53: ProviderFactory{makeRoute53Provider, lego.DNS01},
Expand Down Expand Up @@ -319,3 +326,20 @@ func makeNS1Provider(opts ProviderOpts) (lego.ChallengeProvider, error) {
}
return provider, nil
}

// returns a preconfigured Namecheap lego.ChallengeProvider
func makeNamecheapProvider(opts ProviderOpts) (lego.ChallengeProvider, error) {
if len(opts.NamecheapApiUser) == 0 {
return nil, fmt.Errorf("Namecheap API user is not set")
}

if len(opts.NamecheapApiKey) == 0 {
return nil, fmt.Errorf("Namecheap API key is not set")
}

provider, err := namecheap.NewDNSProviderCredentials(opts.NamecheapApiUser, opts.NamecheapApiKey)
if err != nil {
return nil, err
}
return provider, nil
}
Loading