Skip to content

Commit 0677e7c

Browse files
r1violletclaude
andcommitted
fix(profiling): skip TLS init for non-HTTPS endpoints
Since 9a61cae (perf(profiling): cache TLS in ProfileExporter::new, 2026-02-27), TLS configuration is initialized unconditionally in ProfileExporter::new(), even when the endpoint uses plain HTTP (e.g. agent mode at http://<host>:8126), unix sockets, or named pipes. On Linux this eagerly loads the system CA certificate store via rustls-platform-verifier. In minimal container images (e.g. a bare ubuntu:20.04 without the ca-certificates package), there are no certs to load, so the call fails with: failed to initialize TLS configuration: unexpected error: No CA certificates were loaded from the system This surfaced in ddprof after the libdatadog v29 upgrade: the profiler targets the Datadog agent over HTTP and has no reason to touch the cert store at all. Fix: only call cached_tls_config() and apply tls_backend_preconfigured() when the endpoint scheme is "https". All other schemes (http, unix, windows, file) bypass TLS initialization entirely. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent db9b9f4 commit 0677e7c

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

libdd-profiling/src/exporter/profile_exporter.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,14 @@ impl ProfileExporter {
7878
mut tags: Vec<Tag>,
7979
endpoint: Endpoint,
8080
) -> anyhow::Result<Self> {
81-
let tls_config = super::tls::cached_tls_config()?;
81+
// Only initialize TLS for HTTPS endpoints. HTTP, unix, windows, and file
82+
// endpoints don't use TLS, and eagerly loading the system cert store can
83+
// fail in minimal container environments with no CA certificates installed.
84+
let tls_config = if endpoint.url.scheme_str() == Some("https") {
85+
Some(super::tls::cached_tls_config()?)
86+
} else {
87+
None
88+
};
8289
// Pre-build all static headers
8390
let mut headers = reqwest::header::HeaderMap::new();
8491

@@ -123,7 +130,10 @@ impl ProfileExporter {
123130
let base_tags_string: String = tags.iter().flat_map(|tag| [tag.as_ref(), ","]).collect();
124131

125132
let (builder, request_url) = endpoint.to_reqwest_client_builder()?;
126-
let builder = builder.tls_backend_preconfigured(tls_config.0);
133+
let builder = match tls_config {
134+
Some(tls) => builder.tls_backend_preconfigured(tls.0),
135+
None => builder,
136+
};
127137

128138
Ok(Self {
129139
client: builder.build()?,

0 commit comments

Comments
 (0)