fix: fall back to system trust store when CA cert is absent from TLS …#1698
Open
asaxena7-atlas wants to merge 1 commit intoOT-CONTAINER-KIT:mainfrom
Open
fix: fall back to system trust store when CA cert is absent from TLS …#1698asaxena7-atlas wants to merge 1 commit intoOT-CONTAINER-KIT:mainfrom
asaxena7-atlas wants to merge 1 commit intoOT-CONTAINER-KIT:mainfrom
Conversation
8c36180 to
c6fe234
Compare
| return &tls.Config{ | ||
| Certificates: []tls.Certificate{cert}, | ||
| MinVersion: tls.VersionTLS12, | ||
| InsecureSkipVerify: true, //nolint:gosec // No CA cert available; skip server verification |
Check failure
Code scanning / CodeQL
Disabled TLS certificate check
| return &tls.Config{ | ||
| Certificates: []tls.Certificate{cert}, | ||
| MinVersion: tls.VersionTLS12, | ||
| InsecureSkipVerify: true, //nolint:gosec // No CA cert available; skip server verification |
Check failure
Code scanning / CodeQL
Disabled TLS certificate check
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #1698 +/- ##
=======================================
Coverage ? 29.60%
=======================================
Files ? 84
Lines ? 6709
Branches ? 0
=======================================
Hits ? 1986
Misses ? 4523
Partials ? 200 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Hey folks, can some take a look at this PR? @shubham-cmyk @drivebyer @iamabhishek-dubey |
2354560 to
30e7593
Compare
…secret Make CA certificate optional: when CaCertFile is not explicitly set and ca.crt is missing from the secret, use the system certificate pool instead of failing. Explicitly configured but missing CA keys still fail as misconfiguration. Signed-off-by: asaxena7-atlas <208444049+asaxena7-atlas@users.noreply.github.com>
30e7593 to
e3502ec
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
When using TLS with publicly trusted certificates (e.g. Let's Encrypt, Google Trust Services), users no longer need to supply a
ca.crtin their TLS secret. The operator’s container image already trusts these CAs via its system trust store. Previously, the operator would fail ifca.crtwas missing from the secret, even when it wasn’t needed.This change makes the CA certificate optional:
CaKeyFileis not explicitly set in the CR andca.crtis absent from the secret, the operator falls back to the system trust store (RootCAs: nilin Go’stls.Config).CaKeyFileis explicitly set but the corresponding key is missing from the secret, the operator fails fast with a clear error (treating it as misconfiguration).redis-clicommands, health probes, and exporter env vars conditionally omit--cacert/REDIS_EXPORTER_TLS_CA_CERT_FILEwhen no explicit CA is configured, preventing references to non-existent files.Fixes #1697.
Type of change
Checklist
Additional context
Files changed:
internal/k8sutils/secrets.gogetRedisTLSConfignow returns atls.ConfigwithRootCAs = nil(system trust) when the CA is absent and not explicitly configured.internal/controller/common/redis/heal.gogetRedisTLSConfig.internal/k8sutils/redis.gogetRedisTLSArgsomits--cacertwhenCaKeyFileis empty.internal/k8sutils/statefulset.goGenerateTLSEnvironmentVariablesandgetExporterEnvironmentVariablesconditionally emit CA-related env vars.GenerateAuthAndTLSArgsand health probes now use shell parameter expansion (${REDIS_TLS_CA_KEY:+--cacert ...}) to conditionally include--cacert.Tests
secrets_test.go,redis_test.go, andstatefulset_test.gohave been updated to cover absent-CA scenarios.This change is fully backward compatible: existing setups that include
ca.crtin their secret continue to work identically.