← Back to Pull requests

feat: Add an internal option to supply CA certificates to libcurl #433

Closed
unknown closed this pull request without merging on Nov 09, 2026 16:04 UTC
View on GitHub
unknown unknown commented on Nov 06, 2026 23:11 UTC
Author

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-cpp code against the libcurl.a that'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_SetCaCertificates copies the data, like the other CoreConfig setters. dd_core_config_internal_set_ca_certificates stores only a pointer and size, because dd_core_config_t holds its strings inline at fixed maximum lengths, which doesn't suit a certificate bundle. The caller must keep the data valid until dd_core_create returns, since that call copies it while converting the config.

    ## The HTTP client receives options when it's created

    CoreSubsystems::Init creates the HTTP subsystem before the C API converts its config, so IHttpSubsystem::CreateClient now takes HttpClientOptions and a DiagnosticLogger instead. Core::Init passes a view into its own config, which outlives the client, so the libcurl client can pass the data with CURL_BLOB_NOCOPY rather than having curl copy it on every request. The client sets CURLOPT_CAINFO_BLOB before each request, because curl_easy_reset clears 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_BLOB requires 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/ and tests/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 of dd-sdk-unreal that depends on this change.

    [RUM-19172]: https://datadoghq.atlassian.net/browse/RUM-19172?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ

    Diff: 429 lines (+321 / -108) across 5 files Reviewer: fuzzybinary Review duration: 3893m
    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
    0.45
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    56%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    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
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 56.8% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 45.1% (MEDIUM) · Higher = larger blast radius
    45.1%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 56.8% · Lower = rushed or shallow review
    56.8%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 19.5% · Safe to merge
    19.5%