feat: Add an internal option to supply CA certificates to libcurl #433
All Vouch review confidence checks passed
Residual risk 0.20 = Change Risk (0.45) × (1 − Review Confidence (0.57)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.45 · 429 lines diff across 5 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.363
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #433"
general
weight: 0.35
fuzzybinary
refs: RUM-19851
This PR adds an internal-only config option that lets a cross-platform SDK supply dd-sdk-cpp with a certificate authority (CA) bundle in PEM format, via:
config.Internal_SetCaCertificates(my_ca_pem_data);(C++)dd_core_config_internal_set_ca_certificates(config, data, size);(C)The option affects only the libcurl HTTP client, so it has no effect on WinHTTP. When the option is unset, behavior is unchanged.
The primary motivation for this change is Unreal Engine support, particularly in Linux builds, which dd-sdk-unreal is adding in RUM-19172. Whereas Windows builds use WinHTTP and macOS builds rely on a system-installed libcurl, in Linux builds we must link our
dd-sdk-cppcode against thelibcurl.athat's bundled with Unreal Engine. Unreal builds libcurl with no default CA bundle or directory, and instead provides its own TLS configuration at runtime, typically by loading a CA bundle from a .pak file.With this option, dd-sdk-unreal can pass dd-sdk-cpp the CA bundle that Unreal uses. Without it, dd-sdk-cpp's libcurl client would start TLS connections with no trusted root certificates, and every upload would fail peer verification.
## The C API borrows the data until dd_core_create returns
CoreConfig::Internal_SetCaCertificatescopies the data, like the otherCoreConfigsetters.dd_core_config_internal_set_ca_certificatesstores only a pointer and size, becausedd_core_config_tholds its strings inline at fixed maximum lengths, which doesn't suit a certificate bundle. The caller must keep the data valid untildd_core_createreturns, since that call copies it while converting the config.## The HTTP client receives options when it's created
CoreSubsystems::Initcreates the HTTP subsystem before the C API converts its config, soIHttpSubsystem::CreateClientnow takesHttpClientOptionsand aDiagnosticLoggerinstead.Core::Initpasses a view into its own config, which outlives the client, so the libcurl client can pass the data withCURL_BLOB_NOCOPYrather than having curl copy it on every request. The client setsCURLOPT_CAINFO_BLOBbefore each request, becausecurl_easy_resetclears it.## Rejected certificate data is logged once as an error
The upload thread logs transport errors only at Debug level, which the default diagnostic threshold hides. The libcurl client therefore logs an Error the first time curl either rejects the option, for example because its TLS backend can't load certificates from memory, or fails to load the data during the TLS handshake (
CURLE_SSL_CACERT_BADFILE). If curl rejects the option, requests proceed with curl's default CA location.CURLOPT_CAINFO_BLOBrequires curl 7.77.0, and the build sets no minimum version for a system libcurl, so a build against older curl still compiles and logs an error when the option is set.## Tests
Tests in
tests/cpp/andtests/c/cover the config plumbing. They check that the data reaches the mock HTTP client, that the C++ setter copies it, and that the C setter borrows it until conversion and honors the size for data that isn't null-terminated. I also manually validated a working Linux build ofdd-sdk-unrealthat depends on this change.[RUM-19172]: https://datadoghq.atlassian.net/browse/RUM-19172?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ