Skip to content

Managers: Ability to call GetCertificate from external certificate sources#163

Merged
mholt merged 12 commits intomasterfrom
getcert
Feb 17, 2022
Merged

Managers: Ability to call GetCertificate from external certificate sources#163
mholt merged 12 commits intomasterfrom
getcert

Conversation

@mholt
Copy link
Copy Markdown
Member

@mholt mholt commented Jan 19, 2022

This is useful if another entity is managing certificates and can provide its own certs dynamically during handshakes.

For example, Tailscale's client has a GetCertificate() function: https://pkg.go.dev/tailscale.com/client/tailscale#GetCertificate

mholt added 2 commits January 19, 2022 14:02
Useful if another entity is managing certificates and can
provide its own dynamically during handshakes.
mholt added 6 commits January 22, 2022 10:50
This is only sorta true, but it allows handshake-time maintenance of the
certificates that are cached from CustomGetCertificate.

Our background maintenance routine skips certs that are OnDemand so it
should be fine.
Hostnames are case-insensitive

Also add context to GetCertificate
Also minor refactoring and enhancements
@mholt
Copy link
Copy Markdown
Member Author

mholt commented Feb 14, 2022

(I'm pretty much ready to merge this, but I am spending some time double-checking the On-Demand coupling to CustomGetCertificate, since I wonder if it's possible to use CustomGetCertificate without requiring on-demand.)

@mholt mholt changed the title Support custom GetCertificate function Managers: Ability to call GetCertificate from external certificate sources Feb 17, 2022
@mholt mholt merged commit 797d29b into master Feb 17, 2022
@mholt mholt deleted the getcert branch February 17, 2022 21:37
@mholt
Copy link
Copy Markdown
Member Author

mholt commented Feb 17, 2022

And that's a wrap! I think. 🙂

Instead of CustomGetCertificate or CertificateGetter, I called the interface CertificateManager, since we expect that whatever is on the other end of GetCertificate() is managing the certificate for us (keeping it renewed).

It no longer implicitly enables or requires On-Demand TLS to be enabled; they are orthogonal concepts.

Thank you to Tailscale for making this change possible!

crccw pushed a commit to crccw/certmagic that referenced this pull request Feb 23, 2022
…ver#163)

This work made possible by Tailscale: https://tailscale.com - thank you to the Tailscale team!

* Implement custom GetCertificate callback

Useful if another entity is managing certificates and can
provide its own dynamically during handshakes.

* Refactor CustomGetCertificate into OnDemandConfig

* Set certs to managed=true

This is only sorta true, but it allows handshake-time maintenance of the
certificates that are cached from CustomGetCertificate.

Our background maintenance routine skips certs that are OnDemand so it
should be fine.

* Change CustomGetCertificate into interface value

Instead of a function

* Case-insensitive subject name comparison

Hostnames are case-insensitive

Also add context to GetCertificate

* Export a couple of outrageously useful functions

* Allow multiple custom certificate getters

Also minor refactoring and enhancements

* Fix tests

* Rename Getter -> Manager; refactor

And don't cache externally managed certs

* Minor updates to comments
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.

1 participant