mirror of
https://github.com/acme-dns/acme-dns.git
synced 2026-04-27 04:45:48 +03:00
[GH-ISSUE #126] Create certificates for multiple hosts without adding a CNAME record for each? #48
Labels
No labels
Documentation
Documentation
bug
enhancement
feature request
feature request
help wanted
pull-request
question
security
security
testing
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/acme-dns#48
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @mdbraber on GitHub (Nov 6, 2018).
Original GitHub issue: https://github.com/acme-dns/acme-dns/issues/126
First off, thanks for building acme-dns - it's just what I was looking for! I'm trying to do the following: I want to generate certificates for the servers foo.example.org, bar.example.org etc. This works fine. However I have to manually add the following in my providers DNS config:
As the hosts (
foo,baretc.) are being created rather dynamic I would prefer to prevent creating them by hand if possible (also I would prefer to keep the names of the hosts out of my providers DNS. Wildcards obviously won't work and I don't want to generate a wildcard certificate on each hosts as that seems more of a workaround than a real solution.The only solution so far that I could think of would be to use my providers API to somehow dynamically create the
_acme-challenge.foorecord. I would have need to have the client (e.g. lego) to do this before requesting the _acme-challenge record. But unfortunately this implies a 'race' condition because to do that I would put my API keys on each host (which is exactly what I'm trying to prevent with acme-dns).Would there be any (other) ideas to do this smarter / more dynamic?
@joohoi commented on GitHub (Nov 6, 2018):
Thanks for your kind words!
As you correctly pointed out, acme-dns was created to prevent saving the all-powerful DNS zone credentials on each box that needs to automate DNS challenges. The automation will unfortunately require keeping the CNAME records in the main zone intact to be able to do its magic.
The nature of the records is static, so they need to be created only once, so kind of fire & forget approach to the issue as they will be reused with the created pair of credentials on every automated renewal.
Something to point up though; to steer people towards secure configuration practices, acme-dns only allows two simultaneous TXT record per generated subdomain (for the purpose of getting wildcard and the main domain to the same certificate:
*.example.organdexample.org, both of which need to use the_acme-challenge.example.orgdomain for TXT records).Back to the original question: could you help me understand the situation better? I would like to know why you'd prefer removing the CNAME records from the main zone outside of the challenge validation. I know there are multiple possible reasons for that though, just don't know what you are facing currently!
@mdbraber commented on GitHub (Nov 6, 2018):
First off - this is all more or less artificial as I'm not running this in production but rather in my homelab. But still I'm trying to see if I can make this work. It's mostly that I would prefer not to have to create separate CNAME records when hosts are brought up / taken down rather quickly. Yes, normally this would be fire and forget, but with containers as I'm using this is rather frequent.
Does that clarify things?
@mdbraber commented on GitHub (Nov 6, 2018):
Here's my idea for a solution so far:
askwhether a domain is allowed to be created: https://caddyserver.com/docs/automatic-https#on-demandThen I can specifiy a server listening to the
askrequest (e.g. on the same host as acme-dns) that can dynamically create the host if it's allowed to be created. As I have all my hostnames mapped internally to the domain I'd like to use (using an internal DNS resolver), I could resolve the requesting IP and use that name to determine which DNS record to add.Any other ideas are welcome!
@mdbraber commented on GitHub (Nov 6, 2018):
Another idea: if I could supply the username when registering (instead of being dynamic) I could easily create a DNS record like:
_acme-challenge.foo CNAME foo.auth.example.orgThat would probably be the most clean / dynamic (and also easiest to keep track of created domains / certificates. Would there be something that prevents usernames from being dynamic (security concerns or otherwise?)
@Ajedi32 commented on GitHub (Nov 6, 2018):
I'm confused. Are you saying you want to automate the registration of new hostnames, but without allowing a service to get certificates for a hostname that a different service already registered, and with some other arbitrary restrictions on what hostnames are allowed to be created?
@mdbraber commented on GitHub (Nov 6, 2018):
@Ajedi32 I'm sorry, it might be a bit convoluted, but I'll try to clarify:
The only 'problem' is that I still have to manually add a
_acme-challenge.foorecord to my DNS. To prevent that I'm trying to think of a solution to create those records dynamically (because I can't use wildcards for something like_acme-challenge.*).My idea is now is to use Caddy with
acmednsso it could automatically request a certificate. Before requesting a certificate (thetls askvariable) it would be able to query a URL to see if the host is allowed to receive a certificate. If I would have a server listening on that URL that creates the_acme-challenge.foorecord when it's queried (based on the internally mapped hostname linked to the requesting IP). That way the certificates that can be created are limited to which hosts I have intnerally mapped and automatic@Ajedi32 commented on GitHub (Nov 6, 2018):
Ah. Yeah, that seems like it would work. That way you can program the server to enforce any restrictions you want for hostname creation.
@mdbraber commented on GitHub (Nov 7, 2018):
I'm trying to understand what goes on when a certificate is being issues by LE. I've tried researching, but I can't yet fully wrap my head around what's going on. So here's my understanding so far:
Suppose we have an
acme-dnsconfiguration for domaintest.example.orgwhich needs to redirect with a CNAME toUUID.auth.example.org:acme-dnsfor domaintest.example.orgwith credentials that link to domainUUID.auth.example.orgacme-dns/updateendpoint with the provided challenge forUUID.auth.example.org_acme-challenge.test.example.orgto see if it contains a CNAMEUUID.auth.example.orgthat host is queried andacme-dnsprovides the correct TXT responseWould it work if between step 2 and 3 I let acme-dns dynamically create the CNAME? That way I would only have my DNS provider credentials stored at one single location.
@mdbraber commented on GitHub (Nov 7, 2018):
I've created this simple Go server to create / destroy the required CNAME records (which can be called by just a simple POST request with the corresponding JSON: https://github.com/mdbraber/update-cname-server
@Ajedi32 commented on GitHub (Nov 7, 2018):
Well, sort of. It check's if
_acme-challenge.test.example.orgcontains the correct TXT record, but finds a CNAME instead, so it follows the CNAME redirect toUUID.auth.example.organd checks if that contains the correct TXT record.Yes, but at that point I don't see why you wouldn't just have it create the TXT record directly. No need for acme-dns when you have a way to fulfill the challenge yourself.
@Ajedi32 commented on GitHub (Nov 7, 2018):
It seems like you might be better off writing an acme-dns alternative instead of using ACME-DNS. You basically just want some kind of DNS API proxy that fulfills requests to set TXT records on your upstream DNS (just like ACME clients do) but with restrictions so clients can't just update whatever records they want.
That can be done without needing a whole separate DNS server, so I think it's better implemented as a separate project rather than an add-on to ACME-DNS.
I've actually kinda been wanting something like that for a while now; a centralized server that can fulfill ACME challenges for other devices on the network, provided they meet certain authorization conditions. ACME-DNS sorta fulfills that use-case, but only for one "authorization condition": manual approval (by setting a CNAME record) for a specific acme-dns account to authorize certs for a specific domain.
@mdbraber commented on GitHub (Nov 8, 2018):
@Ajedi32 you're right. My setup works, but it's indeed not needed to use acme-dns for this. Therefore I've quickly written acme-proxy . This might be an alternative for those people who do have access to their DNS providers' API, but would like to centralize requests.
It integrates with lego and can basically proxy all the providers. To use it now, use my current fork of lego that integrates acme-proxy as a provider. I've created a PR with lego to gather suggestions for a better implementation: https://github.com/xenolf/lego/pull/708. It works great at this moment:
Running the proxy:
Requesting a certificate:
@wdoekes commented on GitHub (Mar 18, 2019):
You might wat to take a look at our changes mentioned in #158, where you can use "readable" CNAMEs and a single set of credentials to manage multiple TXT records.
@mdbraber commented on GitHub (May 13, 2019):
Thanks @wdoekes looks interesting. For anyone interested in a different solution to the same problem, check out https://github.com/mdbraber/acmeproxy for an updated version of acmeproxy that's basically relaying requests from other hosts inside a network (having credential stored in a single location) and can use username/password or IP based authentication.