Skip to content

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

Description

@thswlsqls

Describe the bug

TlsConfigHelper documents that the PEM-based higher level API and the lower level setSslContext are mutually exclusive, but the keyManager / sslContext combination is not checked. Configuring both silently drops the client certificate.

Steps to reproduce

OtlpHttpSpanExporter.builder()
    .setClientTls(privateKeyPem, certificatePem)   // sets keyManager
    .setSslContext(sslContext, trustManager)       // no exception
    .build();                                      // client certificate is gone

What did you expect to see?

An IllegalStateException. The class Javadoc says the two APIs may be used "but NOT both", and OtlpHttpSpanExporterBuilder.setSslContext says "Users should call this or set raw certificate bytes, but not both". The trustManager side already enforces this in both directions.

What did you see instead?

Both calls succeed. setSslContext (line 95) checks only sslContext and trustManager; setKeyManagerFromCerts (line 72) checks only keyManager. HttpExporterBuilder and GrpcExporterBuilder read getSslContext() and getTrustManager() only, so the key manager never reaches the connection. Against an mTLS collector this surfaces as an unexplained handshake failure.

What version and what artifacts are you using?

Artifacts: opentelemetry-exporter-common, opentelemetry-exporter-otlp
Version: main @ d948e13 (1.66.0-SNAPSHOT)
How did you reference these artifacts? Built from source.

Environment

Compiler: Temurin 21
OS: N/A

Additional context

N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions