Skip to content

Conversation

@eloekset
Copy link

@eloekset eloekset commented Jul 18, 2022

An implemenation for Namecheap.

I've deployed and used it for three of my own domains now and it works fine.

Since I can't send PRs for the wiki, this is the documentation that should be added about configuration of the Namecheap provider:

Namecheap

App settings

  • Acmebot:Namecheap:ApiKey
    • Your Namecheap username (not an email address)
  • Acmebot:Namecheap:ApiKey
    • API Key on your Namecheap Profile -> Tools -> API Access page

Example API Token configuration

Navigate to https://ap.www.namecheap.com/settings/tools/apiaccess/

image

Client IP addresses must be whitelisted in your Namecheap account to be able to call the API. For Azure Function apps, this is a bit tricky, because you don't know which IP address the function app uses until it has tried and got rejected.

To find the IP address, you'll have to look at the Application Insights Performance view and look for logs on GetZones. There you should find an entry for api.namecheap.com GET /xml.response and the Path contains the ClientIp=nn.nnn.nn.nnn parameter showing the IP address that was used.

image

You have to go to your Namecheap profile page and whitelist this IP address.

image

But there's no guarantee that the function app uses the same IP address when it renews the certificates some months later.

@eloekset
Copy link
Author

Link to Issue #490

@eloekset eloekset force-pushed the feature/namecheap-to-upstream branch from 3a51a14 to 2817068 Compare August 13, 2022 09:35
dnsProviders.TryAdd(options.Gandi, o => new GandiProvider(o));
dnsProviders.TryAdd(options.GoDaddy, o => new GoDaddyProvider(o));
dnsProviders.TryAdd(options.GoogleDns, o => new GoogleDnsProvider(o));
dnsProviders.TryAdd(options.Namecheap, o => new NamecheapProvider(o, HttpClientFactory.Create(), HttpClientFactory.Create()));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HttpClient should be instantiated inside the Provider. Implementation uniformity with other Providers is important.

public const string GetHostsCommand = "namecheap.domains.dns.getHosts";
public const string SetHostsCommand = "namecheap.domains.dns.setHosts";

public NamecheapProvider(NamecheapOptions options, HttpClient namecheapHttpClient, HttpClient ipfyOrgHttpClient)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As with other Providers, the implementation of the IDnsProvider interface should be separated from the DNS API implementation class.

This is necessary for implementation consistency as well as to be resilient to future API changes.


var ipFyResponse = await response.Content.ReadAsAsync<IpfyResponse>();

return ipFyResponse.Ip;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Azure Functions do not always match the Outbound IP between each request. Therefore, there is a possibility of unintended behavior when the obtained Outbound IP changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants