-
Notifications
You must be signed in to change notification settings - Fork 158
docs(interceptor): document TLS SNI certificate selection #1609
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -122,3 +122,13 @@ make e2e-test E2E_ARGS="--dry-run" | |
| The `PROFILE` variable selects a test profile directory under `test/e2e/` (e.g. `PROFILE=tls` runs `./test/e2e/tls/...`). Each subdirectory in `test/e2e/` is a profile. | ||
| The `RUN` variable filters tests by name using Go's `-run` flag (supports regex, e.g. `RUN=TestColdStart` or `RUN="TestHost|TestPath"`). | ||
| The `E2E_ARGS` variable passes flags to the [e2e-framework](https://github.com/kubernetes-sigs/e2e-framework) via `-args` (e.g. `--labels`, `--feature`, `--skip-labels`, `--dry-run`). | ||
|
|
||
| ### TLS SNI behavior | ||
|
|
||
| The interceptor can serve more than one certificate from the TLS listener by setting `KEDA_HTTP_PROXY_TLS_CERT_STORE_PATHS` to one or more directories that contain certificate/key pairs. During the TLS handshake it: | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done — the docs now call out that |
||
|
|
||
| 1. Looks for an exact match between the client SNI value and a certificate SAN loaded from the configured certificate-store directories. | ||
| 2. Falls back to the certificate from `KEDA_HTTP_PROXY_TLS_CERT_PATH` and `KEDA_HTTP_PROXY_TLS_KEY_PATH` when no SNI-specific certificate matches. | ||
| 3. Fails the handshake when there is no matching SNI certificate and no default certificate is configured. | ||
|
|
||
| The existing `test/e2e/tls` profile covers successful TLS termination. The interceptor unit tests in `interceptor/tls_config_test.go` additionally cover the no-match fallback and no-default error paths. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -79,6 +79,34 @@ func TestBuildTLSConfig_FallbackToDefault(t *testing.T) { | |
| requireCertForHost(t, tlsCfg, "unknown.example.com") | ||
| } | ||
|
|
||
| func TestBuildTLSConfig_PrefersSNIMatchOverDefault(t *testing.T) { | ||
| dir := t.TempDir() | ||
| writeCert(t, dir, "default", "default.example.com") | ||
| writeCert(t, dir, "app", "app.example.com") | ||
|
|
||
| opts := TLSOptions{ | ||
| CertificatePath: filepath.Join(dir, "default.crt"), | ||
| KeyPath: filepath.Join(dir, "default.key"), | ||
| CertStorePaths: dir, | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done — I moved the additional certificate into a separate temp store directory so the test exercises SNI preference without re-loading the default cert via the store path. |
||
| } | ||
|
|
||
| tlsCfg, err := BuildTLSConfig(opts, logr.Discard()) | ||
| if err != nil { | ||
| t.Fatalf("failed to build TLS config: %v", err) | ||
| } | ||
|
|
||
| cert, err := tlsCfg.GetCertificate(&tls.ClientHelloInfo{ServerName: "app.example.com"}) | ||
| if err != nil { | ||
| t.Fatalf("expected SNI-matched certificate, got error: %v", err) | ||
| } | ||
| if cert == nil || cert.Leaf == nil { | ||
| t.Fatal("expected certificate leaf to be populated") | ||
| } | ||
| if got := cert.Leaf.DNSNames; len(got) != 1 || got[0] != "app.example.com" { | ||
| t.Fatalf("expected app.example.com certificate, got %v", got) | ||
| } | ||
| } | ||
|
|
||
| func TestBuildTLSConfig_NoDefaultCert(t *testing.T) { | ||
| opts := TLSOptions{} | ||
|
|
||
|
|
||
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.
We moved the docs a few hours before you opened the PR here, could you move it there? https://keda.sh/http-add-on/0.14/operations/configure-tls/ (See the Suggest changes button)