Skip to content

fix: don't request client cert SDS when only CAFile is set#23679

Open
mrgupta7 wants to merge 4 commits into
mainfrom
mridul/tgw-sds-bug
Open

fix: don't request client cert SDS when only CAFile is set#23679
mrgupta7 wants to merge 4 commits into
mainfrom
mridul/tgw-sds-bug

Conversation

@mrgupta7

@mrgupta7 mrgupta7 commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Description

When a Terminating Gateway service is configured with only CAFile (one-way TLS), makeUpstreamTLSContext was unconditionally emitting a TlsCertificateSdsSecretConfigs entry for svc-cert. Since no client cert is configured, the SDS server never pushes that secret, leaving Envoy's upstream cluster stuck in a permanent warming state and dropping all traffic to that service.

Updated the existing tests to handle such scenarios.

Testing & Reproduction steps

Tested with the setup - 200 OK response.

curl -v http://127.0.0.1:5000

*   Trying 127.0.0.1:5000...
* Connected to 127.0.0.1 (127.0.0.1) port 5000
> GET / HTTP/1.1
> Host: 127.0.0.1:5000
> User-Agent: curl/8.7.1
> Accept: */*
> 
* Request completely sent off
< HTTP/1.1 200 OK
...

Links

Test Results

Envoy dynamic_active_cluster before fix

"common_tls_context": {
                  "tls_certificate_sds_secret_configs": [
                    {
                      "name": "external-dns-service-cert",
                      "sds_config": {
                        "ads": {},
                        "resource_api_version": "V3"
                      }
                    }
                  ],
                  "validation_context_sds_secret_config": {
                    "name": "external-dns-service-ca",
                    "sds_config": {
                      "ads": {},
                      "resource_api_version": "V3"
                    }
                  }
                }

Envoy dynamic_active_cluster after fix

"common_tls_context": {
         "validation_context_sds_secret_config": {
          "name": "external-dns-service-ca",
          "sds_config": {
           "ads": {},
           "resource_api_version": "V3"
          }
         }
        }
       }

PR Checklist

  • updated test coverage
  • external facing docs updated
  • appropriate backport labels added
  • not a security concern

PCI review checklist

  • I have documented a clear reason for, and description of, the change I am making.

  • If applicable, I've documented a plan to revert these changes if they require more than reverting the pull request.

  • If applicable, I've documented the impact of any changes to security controls.

    Examples of changes to security controls include using new access control methods, adding or removing logging pipelines, etc.

@mrgupta7 mrgupta7 requested review from a team as code owners June 19, 2026 12:48
@github-actions github-actions Bot added the theme/envoy/xds Related to Envoy support label Jun 19, 2026
@mrgupta7 mrgupta7 self-assigned this Jun 19, 2026
@mrgupta7 mrgupta7 added backport/ent/1.21 changes are backported to 1.21 ent backport/1.22 Changes are backported to 1.22 backport/ent/1.22 Changes are backported to 1.22 ent backport/2.0 Changes are backported to 2.0 backport/ent/2.0 Changes are backported to 2.0 ent labels Jun 19, 2026
@github-actions

github-actions Bot commented Jun 19, 2026

Copy link
Copy Markdown

Go Test Coverage: 61.7%

See the workflow run for the full per-package breakdown and downloadable HTML report.

@codecov-commenter

codecov-commenter commented Jun 19, 2026

Copy link
Copy Markdown

Codecov Report

Caution

This repository is currently using the Sentry GitHub App to receive Codecov PR comments. This integration will be deprecated on July 8, 2026. Please install the Codecov GitHub App to continue receiving coverage reports on your pull requests.
✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 59.36%. Comparing base (313b0ed) to head (012656e).

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #23679      +/-   ##
==========================================
- Coverage   59.67%   59.36%   -0.32%     
==========================================
  Files         945      752     -193     
  Lines      114721    91520   -23201     
==========================================
- Hits        68465    54332   -14133     
+ Misses      39902    31867    -8035     
+ Partials     6354     5321    -1033     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread agent/xds/listeners.go
TlsCertificateSdsSecretConfigs: []*envoy_tls_v3.SdsSecretConfig{
{
Name: mapping.Service.Name + "-cert",
ctx := &envoy_tls_v3.CommonTlsContext{

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the difference in behaviour because of the code changes now ?

https://github.com/hashicorp/consul-enterprise/blob/main/agent/xds/secrets.go#L71
already we have published secrets via SDS .
here the reference is only provided as name.

@mrgupta7 mrgupta7 Jun 24, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated the envoy config changes before and after fix in description

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport/ent/1.21 changes are backported to 1.21 ent backport/ent/1.22 Changes are backported to 1.22 ent backport/ent/2.0 Changes are backported to 2.0 ent backport/1.22 Changes are backported to 1.22 backport/2.0 Changes are backported to 2.0 theme/envoy/xds Related to Envoy support

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants