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 ACME protocol support for certificate management into TLS plugin #13

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

mariuskimmina
Copy link

This is a first draft and still contains open questions, and is subject to change.

I hope to work on this project in the context of Goolge Summer of Code (GSoC) and will be applying for that in the upcoming application period from April 04 - April 19.

I saw that there were 2 previous proposals for an ACME addition and reused a lot of there work - so a lot of credit goes to them and hopefully the third times the charm.

Signed-off-by: Marius Kimmina <[email protected]>
@mariuskimmina
Copy link
Author

Following up on our discussion on the original issue, I updated the proposal so that only the DNS challenge will be supported by this change, the HTTP challenge is out of scope. CoreDNS also needs to be the authoritative DNS server for the domain.

@mariuskimmina mariuskimmina marked this pull request as ready for review April 13, 2022 15:14
@mariuskimmina
Copy link
Author

Hey @yongtang, I would appreciate some feedback on this when you can find the time. I have also send in my application for GSoC - so I'm sure that I want to work on this.

@yongtang
Copy link
Member

@mariuskimmina The proposal overall looks great! I also saw your proposal in GSoC's page. /cc @greenpau

@mariuskimmina
Copy link
Author

mariuskimmina commented May 4, 2022

So, I started working on this and I am hitting a first roadblock - to solve the DNS Challenge CoreDNS needs to be ready to accept DNS requests, which happens after all the plugins have been parsed.
So, when parsing the TLS plugin and trying to solve the ACME Challenge, CoreDNS is not yet accepting any DNS requests.
What I can do is put the whole ACME Challenge Code into a go-routine and let CoreDNS start while the Challenge Code is being executed - but then (I think) I cannot tell CoreDNS to use the certificate any more because it's already done parsing the config.

So, Ideally when parsing the TLS plugin config I want to be able to start serving DNS just for the challenge and then stop serving DNS again to go on parsing other plugins - is there a way to do something like that? @yongtang @greenpau

@yongtang
Copy link
Member

yongtang commented May 7, 2022

@mariuskimmina Sorry for the late reply. Let me take a look and get back to you during the weekend.

@mariuskimmina
Copy link
Author

mariuskimmina commented May 10, 2022

@yongtang After digging a bit deeper into the core code, I found it to be possible to create barebones (no plugins) dnsserver.Server inside the plugin code and start to serve DNS requests - so it seems doabble to

  1. Start a barebones dnsserver.Server
  2. Start the ACME Challenge
  3. Solve the challenge (wait for a request)
  4. Receive a Certificate
  5. Shutdown the created dnsserver.Server
  6. Continue parsing other plugins as usual

But no other plugin seems to have done something like this - does it seem reasonable to do it this way? I would of course add a timeout to the challenge so that if something goes wrong CoreDNS doesn't get stuck on startup.

Also don't worry about late replies - I appreciate any help I can get

@mariuskimmina
Copy link
Author

Status update: I just successfully solved an ACME DNS Challenge and received a certificate - so the approach seems to be working. Code is still a mess and I need to add a lot of logic around it, but the general approach appears to be working. :)

For my tests I'm using pebble as a CA running on localhost, CoreDNS is also running on localhost and set as the authoritative DNS Server in /etc/resolv.conf
In this setup I can request a certifcate for dns.example.com, CoreDNS answers the dns request to _acme_challenge.example.com and I receive a certificate.

@yongtang
Copy link
Member

@mariuskimmina Happy to let you know that your proposal has been accepted by GSoC. Congratulations 🎉

I am out-of-office this week but I will send you a meeting invite so Paul and me can have a sync up with you. You can also find my email from my github profile.

@mariuskimmina
Copy link
Author

Thanks for bringing me the great news, even before an official anouncement - I am looking forward to talking to you and to bringing this feature into CoreDNS 😀

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