Reject mixing keyManager and sslContext in TlsConfigHelper - #8710
Open
thswlsqls wants to merge 2 commits into
Open
Reject mixing keyManager and sslContext in TlsConfigHelper#8710thswlsqls wants to merge 2 commits into
thswlsqls wants to merge 2 commits into
Conversation
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
marked this pull request as ready for review
August 10, 2026 00:39
Pull request dashboard statusWaiting on reviewers · refreshed 2026-09-02 14:35 UTC Review the latest changes. Status above doesn't look right?
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #8710 +/- ##
============================================
- Coverage 91.65% 91.28% -0.37%
- Complexity 10352 10500 +148
============================================
Files 1003 1006 +3
Lines 27210 28344 +1134
Branches 3199 3584 +385
============================================
+ Hits 24939 25875 +936
- Misses 1566 1675 +109
- Partials 705 794 +89 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
setSslContext also assigns trustManager, so the setSslContext -> setTrustManagerFromCerts case was already rejected by the trustManager check. That check reported "trustManager has been previously configured", which does not name the setter the caller actually used, and it relied on setSslContext requiring a non-null X509TrustManager. Add an explicit sslContext check ahead of the trustManager one so all three setters reject each other the same way, and update the existing test for that path, which pinned the misleading message.
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.
Fixes #8708
Description
TlsConfigHelper.setSslContextdid not checkkeyManagerandsetKeyManagerFromCertsdid not checksslContext, so both APIs could be used on one builder.OtlpHttpSpanExporterBuilder.setSslContexttells users to "call this or set raw certificate bytes, but not both".getSslContext()andgetTrustManager()to the transport and never readgetKeyManager(), so the client certificate was silently dropped.trustManageris already guarded in both directions;keyManagerwas the only asymmetric case.if.Testing done
TlsConfigHelperTest#createKeyManager_AlreadyExists_Throwsand#setSslContext_AlreadyExists_Throwswith opposite-direction blocks, matching the trust manager tests../gradlew :exporters:common:check— 70 tests passed.io.opentelemetry.exporter.internalis excluded from japicmp and no signature changed.