open-telemetry / opentelemetry-rust-contrib

OpenTelemetry Contrib Packages for Rust
Apache License 2.0
35 stars 34 forks source link

[Bug]: Stackdriver exporter fails to build with tonic certificate error when updating to 0.21 #95

Closed msdrigg closed 1 month ago

msdrigg commented 2 months ago

What happened?

When updating from 0.20 to 0.21, I am seeing this error

Error: Logging failed to set up

Caused by:
    0: Failed to init stackdriver exporter
    1: tonic error: transport error
    2: transport error
    3: invalid peer certificate: UnknownIssuer
    4: invalid peer certificate: UnknownIssuer

This is caused by this line in StackDriverExporter::Builder::build

https://github.com/open-telemetry/opentelemetry-rust-contrib/blob/9cd566be64aba0b5256726a5418c6d2abc2d3cd1/opentelemetry-stackdriver/src/lib.rs#L188

I believe the problem is that tonic 0.12 now requires explicitly setting use_webpki_roots() or use_native_roots() in ClientTlsConfig, and does not implicitly default to enabling them if not enabled (See this PR here https://github.com/hyperium/tonic/pull/1731)

So the fix would be to make sure ClientTlsConfig explicitly calls .use_webpki_roots() or .use_native_roots() in all places that they are created (depending on enabled features.

API Version

Crate version 0.20

SDK Version

Crate version 0.24

What component are you working with?

opentelemetry-stackdriver

Relevant log output

Error: Logging failed to set up

Caused by:
    0: Failed to init stackdriver exporter
    1: tonic error: transport error
    2: transport error
    3: invalid peer certificate: UnknownIssuer
    4: invalid peer certificate: UnknownIssuer