-
Notifications
You must be signed in to change notification settings - Fork 607
feat: add lets encrypt challenges #4471
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
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
f873a23
feat: add lets encrypt challenges
Flo4604 852268c
always disable cname following
Flo4604 ea5eb21
cleanup some code
Flo4604 5dc719d
cleanup some code
Flo4604 a3a9278
cleanup some code
Flo4604 ccfdca7
cleanup some code
Flo4604 7b70331
cleanup some code
Flo4604 e5d7d9b
fix golint issues
Flo4604 717add7
fix golint issues
Flo4604 01b0c96
Merge branch 'main' into feat/ctrl-lets-encrypt-challenges
Flo4604 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| package caches | ||
|
|
||
| import ( | ||
| "time" | ||
|
|
||
| "github.com/unkeyed/unkey/go/pkg/cache" | ||
| "github.com/unkeyed/unkey/go/pkg/clock" | ||
| "github.com/unkeyed/unkey/go/pkg/db" | ||
| "github.com/unkeyed/unkey/go/pkg/otel/logging" | ||
| ) | ||
|
|
||
| // Caches holds all shared cache instances for the ctrl application. | ||
| type Caches struct { | ||
| Domains cache.Cache[string, db.CustomDomain] | ||
| Challenges cache.Cache[string, db.AcmeChallenge] | ||
| } | ||
|
|
||
| type Config struct { | ||
| Logger logging.Logger | ||
| Clock clock.Clock | ||
| } | ||
|
|
||
| func New(cfg Config) (*Caches, error) { | ||
| clk := cfg.Clock | ||
| if clk == nil { | ||
| clk = clock.New() | ||
| } | ||
|
|
||
| domains, err := cache.New(cache.Config[string, db.CustomDomain]{ | ||
| Fresh: 5 * time.Minute, | ||
| Stale: 10 * time.Minute, | ||
| MaxSize: 10000, | ||
| Logger: cfg.Logger, | ||
| Resource: "domains", | ||
| Clock: clk, | ||
| }) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| // Short TTL for challenges since they change during ACME flow | ||
| challenges, err := cache.New(cache.Config[string, db.AcmeChallenge]{ | ||
| Fresh: 10 * time.Second, | ||
| Stale: 30 * time.Second, | ||
| MaxSize: 1000, | ||
| Logger: cfg.Logger, | ||
| Resource: "acme_challenges", | ||
| Clock: clk, | ||
| }) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| return &Caches{ | ||
| Domains: domains, | ||
| Challenges: challenges, | ||
| }, nil | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: unkeyed/unkey
Length of output: 1104
🏁 Script executed:
rg -n "LEGO_DISABLE_CNAME_SUPPORT" go/apps/ctrl/run.go -B 5 -A 5Repository: unkeyed/unkey
Length of output: 466
🏁 Script executed:
fd "cloudflare" go/apps/ctrl --type fRepository: unkeyed/unkey
Length of output: 116
🏁 Script executed:
Repository: unkeyed/unkey
Length of output: 4600
🏁 Script executed:
Repository: unkeyed/unkey
Length of output: 1094
🏁 Script executed:
Repository: unkeyed/unkey
Length of output: 3909
🏁 Script executed:
rg -n "cfg\.Acme\.Enabled|if.*Acme" go/apps/ctrl/run.go -B 2 -A 2Repository: unkeyed/unkey
Length of output: 1728
🌐 Web query:
lego LEGO_DISABLE_CNAME_SUPPORT cloudflare DNS-01 challenge impact💡 Result:
Short answer: LEGO_DISABLE_CNAME_SUPPORT controls whether the lego ACME client follows CNAMEs when resolving dns‑01 challenge names. If set (true), lego will NOT follow CNAME aliases; if unset (default) lego will follow them. [1][2]
Impact when using Cloudflare and dns‑01:
Recommendations:
Sources:
Environment variable set globally before ACME providers are created; clarify Cloudflare DNS-01 impact.
The
LEGO_DISABLE_CNAME_SUPPORTsetting is correctly placed after validation but before any ACME DNS providers are instantiated. However, this global environment variable affects both Route53 and Cloudflare providers:*.example.com → loadbalancer.aws.com) that would fail zone lookups._acme-challengevia CNAME to another zone or relies on CNAME flattening. This is only safe if using Cloudflare's standard direct zone record management (not CNAME-delegated challenges).If Cloudflare users employ CNAME-based challenge delegation, this environment variable will cause dns-01 validation failures. Consider either:
🤖 Prompt for AI Agents