Repository navigation
tls: add system and combined CA pool modules - #7406
Conversation
| // LIMITATION: x509.CertPool doesn't expose its certificates, making it impossible | ||
| // to merge multiple pools. Return an error if multiple sources are configured. | ||
| if len(ccp.sources) > 1 { | ||
| return fmt.Errorf("combined CA pool currently supports only a single source due to x509.CertPool API limitations (got %d sources); to use multiple certificate sources, consider using a single 'file' source with multiple pem_file entries, or contribute a fix to expose certificate data from the CA interface", len(ccp.sources)) | ||
| } | ||
|
|
||
| // At this point we have exactly one source | ||
| ccp.pool = ccp.sources[0].CertPool() | ||
|
|
||
| return nil | ||
| } | ||
|
|
||
| // Syntax: | ||
| // | ||
| // trust_pool combined { | ||
| // source <module_name> { | ||
| // <module_config> | ||
| // } | ||
| // } | ||
| // | ||
| // LIMITATION: Currently only a single source is supported due to x509.CertPool | ||
| // API limitations. Specifying multiple sources will result in a provisioning error. | ||
| // To combine multiple certificate files, use a single 'file' source with multiple | ||
| // pem_file entries instead. |
There was a problem hiding this comment.
I have intentionally added limitation comments cause i wasnt aware how to proceed here.
|
"combined merges multiple roots sources" is not satisfied as per issue #7391 and i am erroring out as you see in above comment.
This approach which i think is a breaking change so i wanted to consult with my planned implementation |
|
Happy new year and i reviewed your code and i have two types of solutions type CA interface {
AppendTo(pool *x509.CertPool) error
}This is breaking change because not all CA pools can expose certificates. The second way is creating a secondary interface (non breaking change) type CertificateProvider interface {
Certificates() []*x509.Certificate
}The combined module would then check whether each source implements this interface and merge certificates only from those that do. |
|
Hello @FreyreCorona , thank you for the suggestions! will work on a non-breaking solution. lastly, sorry for the delayed response. forgot about this pr due to work |
|
Nice work on the implementation, let's wait for the review. No worries, we're all busy, and I've been pretty quiet around here these past few days too. |
|
When I first glanced at this, I wondered by I made it return a concrete type instead of an interface, but then remembered that I don't see the point of the Open to discuss this further though |
Thanks for the review! I'm confirming that this PR effectively implements the non-breaking, optional interface approach. To clarify:
|
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
|
Hmm, noted. 🤔 |
* doing it for first time, so not sure if its right.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
There was a problem hiding this comment.
Life was busy in the past few months, and this area of the code proved itself critical, so I had to ensure I have clear mind to go through it before merging.
Hopefully this is the last round of review. I believe I've caught everything.
Definitely understandable. |
|
done the requested changes fad1950 |
This comment was marked as spam.
This comment was marked as spam.
|
Folks, please refrain from the pinging. It is on our list. We are very busy, especially the volunteers who have taken up this PR/issue. The more pinging that happens the more we dismiss the notification on the issue and it goes back to the end of the queue (that's just how GH notifications work, I dunno what other peoples' flows are, but that's mine). |
mohammed90
left a comment
There was a problem hiding this comment.
Thank you for working on this and persevering through the multiple rounds of review! LGTM
|
Thank you so much for guiding me along the process! |
caddy 2.11.3 Created-by: HarmonybrewBot Commit-by: HarmonybrewBot Merged-by: HarmonybrewBot Description: Created by `brew bump` --- Created with `brew bump-formula-pr`. - [ ] `resource` blocks have been checked for updates. <details> <summary>release notes</summary> <pre>This release improves several aspects of Caddy with minor features, bug fixes, and security patches. Thank you to everyone and their bots who contributed to help make this release the best one yet! **Security patches:** - fastcgi: Carrying over a patch from FrankenPHP for a bug that could allow non-PHP files to be executed; collaborated on by @dunglas, @KC1zs4, and @chenjj. - vars: A more thorough fix for GHSA-m2w3-8f23-hxxf, collaborated by @everping and @vnxme. - admin: Array index normalization to prevent remote admin socket auth bypass, by @Amemoyoi and bot. - admin: More rigorous path prefix matching to prevent remote admin socket auth bypass, by @Amemoyoi and bot. We've also merged a couple PRs that fix upstream security bugs in other projects like quic-go and CertMagic. Thank you to @marten-seemann for maintaining quic-go so diligently! ## What's Changed * caddyhttp: Sync placeholder expansion in `vars` and `vars_regexp` by @vnxme in caddyserver/caddy#7573 * caddytls: Avoid ACME fallback for implicit Tailscale *.ts.net policies by @steadytao in caddyserver/caddy#7577 * chore: Resolve recent CI failures by @mholt in caddyserver/caddy#7593 * caddytls: Consolidate empty APs more smartly by @mholt in caddyserver/caddy#7567 * rewrite: skip query rename when source key is absent by @steadytao in caddyserver/caddy#7599 * root: introduce down-propagating Helper.BlockState for other directives/plugins to use by @henderkes in caddyserver/caddy#7594 * http: make zstd checksum configurable by @ottenhoff in caddyserver/caddy#7586 * notify: Always send "READY=1" even after an error by @francislavoie in caddyserver/caddy#7597 * reverseproxy: Fix check for `header_up Host {upstream_hostport}` redundancy by @yubiuser in caddyserver/caddy#7564 * caddytls: Expand placeholders in dns_challenge override_domain tls parameter by @pberkel in caddyserver/caddy#7609 * tls: add system and combined CA pool modules by @HarshPatel5940 in caddyserver/caddy#7406 * vars: Don't expand placeholders in values by @vnxme in caddyserver/caddy#7629 * build(deps): bump go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp from 1.42.0 to 1.43.0 by @dependabot[bot] in caddyserver/caddy#7637 * build(deps): bump the all-updates group across 1 directory with 11 updates by @dependabot[bot] in caddyserver/caddy#7641 * reverseproxy: make stream copy buffer size configurable by @steadytao in caddyserver/caddy#7627 * vars: Add matcher placeholder handling tests by @steadytao in caddyserver/caddy#7640 * build(deps): bump github.com/go-jose/go-jose/v4 from 4.1.3 to 4.1.4 by @dependabot[bot] in caddyserver/caddy#7621 * logging: Add journald encoder wrapper by @steadytao in caddyserver/caddy#7623 * caddyfile: Improve import/global options UX for imports before global options by @steadytao in caddyserver/caddy#7642 * chore: replace `interface{}` with `any` for modernization by @tsinglua in caddyserver/caddy#7571 * chore: bump timberjack to v1.4.1 by @DeRuina in caddyserver/caddy#7618 * logging: Preserve ts for journald-wrapped JSON logs by @steadytao in caddyserver/caddy#7644 * fileserver: show symlink targets verbatim (#7476) by @maxtruxa in caddyserver/caddy#7579 * fix(caddyfile): {block} in snippet by @prettysunflower in caddyserver/caddy#7558 * caddyhttp: Document missing placeholders for escaped URI and prefixed query by @steffenbusch in caddyserver/caddy#7659 * chore: add `AGENTS.md` by @mohammed90 in caddyserver/caddy#7652 * build(deps): bump github.com/jackc/pgx/v5 from 5.8.0 to 5.9.0 by @dependabot[bot] in caddyserver/caddy#7655 * admin: Redact sensitive request headers in API logs by @steadytao in caddyserver/caddy#7578 * reverseproxy: add `lb_retry_match` condition on response status by @seroperson in caddyserver/caddy#7569 * caddyhttp: prefer port 443 in auto-HTTPS and add tests by @mholt in caddyserver/caddy#7666 * fix: Propagate ECH keys to the QUIC listener by @steadytao in caddyserver/caddy#7670 * chore: Use atomics where appropriate by @francislavoie in caddyserver/caddy#7648 * metrics: Implement pushing via OLTP by @dunglas in caddyserver/caddy#7664 * logging: Add regression coverage for rotated file mode by @steadytao in caddyserver/caddy#7620 * httpcaddyfile: Inherit global ACME issuer settings in tls shortcuts by @steadytao in caddyserver/caddy#7617 * build(deps): bump github.com/jackc/pgx/v5 from 5.9.0 to 5.9.2 by @dependabot[bot] in caddyserver/caddy#7668 * admin: require path segment boundary in remote access control by @Amemoyoi in caddyserver/caddy#7673 * reverseproxy: Add ability to clear dynamic upstreams cache during retries by @mholt in caddyserver/caddy#7662 * listeners: clean up stale Unix socket files on Windows by @mfrischknecht in caddyserver/caddy#7676 * admin: reject non-canonical config array indices by @Amemoyoi in caddyserver/caddy#7592 * caddytls: Expand ACME credentials by @tribut in caddyserver/caddy#7554 * caddyauth: set user placeholders before auth rejection by @cyphercodes in caddyserver/caddy#7685 * caddyauth: revert user placeholders on auth rejection by @steadytao in caddyserver/caddy#7688 * chore: Fix golangci-lint 2.12.1 findings by @steadytao in caddyserver/caddy#7690 * httpcaddyfile: accept duration strings for log sampling interval by @tomholford in caddyserver/caddy#7694 * tls: Add alpn to managed HTTPS records by @steadytao in caddyserver/caddy#7653 * caddytls: avoid duplicate automation for wildcard-covered hosts by @Rijul-A in caddyserver/caddy#7697 * docs: add documentation for fileExists and fileStat template functions by @steffenbusch in caddyserver/caddy#7700 * rewrite: escape file matcher paths before rewriting by @cyphercodes in caddyserver/caddy#7683 * metrics: Add nil check for metricsHandler in AdminMetrics.serveHTTP by @Br1an67 in caddyserver/caddy#7553 ## New Contributors * @steadytao made their first contribution in caddyserver/caddy#7577 * @henderkes made their first contribution in caddyserver/caddy#7594 * @yubiuser made their first contribution in caddyserver/caddy#7564 * @pberkel made their first contribution in caddyserver/caddy#7609 * @HarshPatel5940 made their first contribution in caddyserver/caddy#7406 * @tsinglua made their first contribution in caddyserver/caddy#7571 * @maxtruxa made their first contribution in caddyserver/caddy#7579 * @seroperson made their first contribution in caddyserver/caddy#7569 * @Amemoyoi made their first contribution in caddyserver/caddy#7673 * @mfrischknecht made their first contribution in caddyserver/caddy#7676 * @tribut made their first contribution in caddyserver/caddy#7554 * @cyphercodes made their first contribution in caddyserver/caddy#7685 * @tomholford made their first contribution in caddyserver/caddy#7694 * @Rijul-A made their first contribution in caddyserver/caddy#7697 * @Br1an67 made their first contribution in caddyserver/caddy#7553 **Full Changelog**: https://github.com/caddyserver/caddy/compare/v2.11.2...v2.11.3</pre> <p>View the full release notes at <a href="https://github.com/caddyserver/caddy/releases/tag/v2.11.3">https://github.com/caddyserver/caddy/releases/tag/v2.11.3</a>.</p> </details> <hr> See merge request: Harmonybrew/homebrew-core!842
Summary
I've implemented the
systemtrust pool module which usesx509.SystemCertPool()and works as expected.However, the
combinedmodule has a fundamental limitation: Go'sx509.CertPooldoesn't expose its certificates, making it impossible to merge multiple pools.so should we modify the CA interface to add a method like
Certificates() []*x509.Certificateso sources can expose their certificates for merging? not sure how to proceed here... Would be happy to learn.Assistance Disclosure
I wrote the code, but Claude generated the tests.