Skip to content

Reject mixing keyManager and sslContext in TlsConfigHelper - #8710

Open
thswlsqls wants to merge 1 commit into
open-telemetry:mainfrom
thswlsqls:fix/tls-config-helper-key-manager-conflict
Open

Reject mixing keyManager and sslContext in TlsConfigHelper#8710
thswlsqls wants to merge 1 commit into
open-telemetry:mainfrom
thswlsqls:fix/tls-config-helper-key-manager-conflict

Conversation

@thswlsqls

Copy link
Copy Markdown
Contributor

Fixes #8708

Description

  • TlsConfigHelper.setSslContext did not check keyManager and setKeyManagerFromCerts did not check sslContext, so both APIs could be used on one builder.
  • Not a new restriction: the class Javadoc says these APIs may be used "but NOT both", and OtlpHttpSpanExporterBuilder.setSslContext tells users to "call this or set raw certificate bytes, but not both".
  • Code that now throws was already broken — senders pass getSslContext() and getTrustManager() to the transport and never read getKeyManager(), so the client certificate was silently dropped.
  • trustManager is already guarded in both directions; keyManager was the only asymmetric case.
  • Existing exception messages are unchanged; each missing direction is a separate if.

Testing done

  • Extended TlsConfigHelperTest#createKeyManager_AlreadyExists_Throws and #setSslContext_AlreadyExists_Throws with opposite-direction blocks, matching the trust manager tests.
  • Both fail when the production change is reverted.
  • ./gradlew :exporters:common:check — 70 tests passed.
  • No apidiff change: io.opentelemetry.exporter.internal is excluded from japicmp and no signature changed.

TlsConfigHelper documents that the PEM-based higher level API and the
lower level setSslContext are mutually exclusive, but only the
trustManager side enforced it. Calling setClientTls followed by
setSslContext passed without error and the client certificate was
silently dropped, because production senders read getSslContext() and
getTrustManager() only.

Add the two missing cross-checks so the documented IllegalStateException
is thrown in both directions, and extend the existing tests to cover
them.
@thswlsqls
thswlsqls marked this pull request as ready for review August 10, 2026 00:39
@thswlsqls
thswlsqls requested a review from a team as a code owner August 10, 2026 00:39
@opentelemetry-pr-dashboard

opentelemetry-pr-dashboard Bot commented Aug 10, 2026

Copy link
Copy Markdown

Pull request dashboard status

Waiting on reviewers · refreshed 2026-08-10 01:36 UTC

Review the latest changes.

Status above doesn't look right?
  • Just replied or pushed? Anything around or after the refresh time above may not be picked up yet — give it a few minutes.
  • Anything look wrong? Report it with what you expected; it helps us improve the dashboard.

@codecov

codecov Bot commented Aug 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.65%. Comparing base (d948e13) to head (7b68e41).

Additional details and impacted files
@@            Coverage Diff            @@
##               main    #8710   +/-   ##
=========================================
  Coverage     91.65%   91.65%           
- Complexity    10352    10354    +2     
=========================================
  Files          1003     1003           
  Lines         27210    27214    +4     
  Branches       3199     3201    +2     
=========================================
+ Hits          24939    24943    +4     
  Misses         1566     1566           
  Partials        705      705           

☔ 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.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TlsConfigHelper silently drops the key manager when an SSLContext is also set

1 participant