by 3dfan · 6y ago · 0 comments
You can point the _acme-challenge
record to another domain using a CNAME
Yes. Then you need two domain name servers to serve your domain. And you need to write and maintain code to talk to the API of the second nameserver.That's what I call a pain in the ass.
Or, as I explained further down, a sub-domain.
> And you need to write and maintain code to talk to the API of the second nameserver.
Which was several dozen lines of shell (used as a hook in our LE client), which we haven't needed to touch since we wrote it a year ago. Hardly a Sisyphean task.
> That's what I call a pain in the ass.
Often less of a pain than dealing with many CAs manually.
Unless you're using a very obscure DNS hosting service you shouldn't need to write any code. There are already made plug-ins for just about everyone.
* Route53. The plug-in is straightforward with the relevant IAM policy to allow a service account to change your records being already written for you. You end up just copying the tokens, and the arn of the zone into the config file and you're off.
* Google CloudDNS. Google's IAM system is a little more complicated if all you want is a DNS hosted zone but once you have a service account with the right permission and the JSON blob in place the plug-in is actually easier to use since it has the ability to programmatically find your zone based on the name instead of copying the arn.
* DNSimple and DigitalOcean. No IAM policy to fiddle with. Just grant an API token from your account, plug it into the config file, and you're done.
* RFC2136. Not super useful unless you're doing on-prem stuff but really nice if you are. The config format for this one is super finnicky and you'll be reading docs to generate the keys but once you have it it's pretty smooth.
How about anyone on the list that's supported by the lexicon utility:
> Lexicon provides a way to manipulate DNS records on multiple DNS providers in a standardized way. Lexicon has a CLI but it can also be used as a python library.
* https://github.com/AnalogJ/lexicon
Doing a quick count, they support 60 APIs.
So, you can just put that nameserver on any machine that has a static IP address, or even a semi-static address, like, your home router or something.
If you are a mega-corp and have multiple country-specific domains that redirect (apple.ca/ -> apple.com/ca/) then having most of your DNS be "static" and your scripts only talk to one 'canonical' (sub-)domain (e.g., dnsauth.apple.com) may be less hassle: instead of dealing with scripting n>1 domains, you only have to deal with n=1.
If it is, I wonder if it would be reasonable to build a small stand-alone DNS server specifically to use with Let's Encrypt for this. You run this on your own server, and it only handles the domains that you need to satisfy Let's Encrypt.
Point the _acme-challenge record there with a CNAME on your "real" DNS server, and whenever you are getting or renewing a Let's Encrypt certificate, bring up the small stand-alone server.
When the certificate issues or is renewed, shut down the small stand-alone server.
Some Googling of the form "simple DNS server $LANG" for various programming languages $LANG turns up a few that could provide nice starting points.
Perl: on meta::cpan there is Net::DNS::Nameserver, meant to provide a local nameserver for testing local client resolvers, but would probably be adaptable.
Python: [1] under 50 lines and using no imports other than "socket". It's very minimal, but shows dealing with the protocol. [2] [3] [4] are all using something called "dnslib". [2] is nearly 150 lines, but it is more complicated than we need. It's even using multithreading. Same for [3]. [4] is much similar, and much smaller (comparable to using Net::DNS::Nameserver in Perl). Another library for simple DNS in Python is pydnserver [5].
PHP: I didn't find anything simple. All I found was much more full featured and many more lines of code than we need.
Go: [6].
Bash: [7]. I'm not sure what disturbs me more. That someone made this, or that I searched for it.
Ruby: [8].
[1] http://code.activestate.com/recipes/491264-mini-fake-dns-ser...
[2] https://gist.github.com/andreif/6069838
[3] https://gist.github.com/pklaus/b5a7876d4d2cf7271873
[4] https://stackoverflow.com/questions/33531551/how-to-create-a...
[5] https://pypi.org/project/pydnserver/
[6] https://gist.github.com/walm/0d67b4fb2d5daf3edd4fad3e13b162c...
[7] https://gist.github.com/CheRuisiBesares/f35f71f028926e65191d...