:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(pgcollector): add RDS CA bundle to Docker image for TLS verification (#95380)
Nick Best6a2e652f140d
diff --git a/rust/Cargo.lock b/rust/Cargo.lockindex d8718ce6abbd..97ffee4dca54 100644--- a/rust/Cargo.lock+++ b/rust/Cargo.lock@@ -8998,7 +8998,6 @@ dependencies = ["tower-http 0.5.2","tracing","tracing-subscriber",- "webpki-roots 1.0.6",][[package]]@@ -9034,7 +9033,6 @@ dependencies = ["toml 0.8.23","tracing","tracing-subscriber",- "webpki-roots 1.0.6",][[package]]diff --git a/rust/Dockerfile b/rust/Dockerfileindex 1fe20dee2f63..e9c85ad7ba02 100644--- a/rust/Dockerfile+++ b/rust/Dockerfile@@ -111,6 +111,11 @@ RUN --mount=type=secret,id=posthog_upload_symbols_cli_api_key \FROM debian:bookworm-slim AS runtime+# AWS RDS global CA bundle — all root and intermediate CAs for TLS verification.+# To update: download the bundle, recompute the hash with sha256sum, and replace both values.+# curl -fsS "https://truststore.pki.rds.amazonaws.com/global/global-bundle.pem" | sha256sum+ARG RDS_CA_BUNDLE_SHA256=e5bb2084ccf45087bda1c9bffdea0eb15ee67f0b91646106e466714f9de3c7e3+RUN apt-get update && \apt-get install -y --no-install-recommends \libssl-dev "ca-certificates" \@@ -123,7 +128,12 @@ RUN apt-get update && \chmod -R 755 ./share/GeoLite2-City.mmdb && \mkdir -p /app/share && \mv ./share/GeoLite2-City.mmdb /app/share/ && \- rm -rf ./share+ rm -rf ./share && \+ curl -fsS -o /tmp/rds-combined-ca-bundle.crt \+ "https://truststore.pki.rds.amazonaws.com/global/global-bundle.pem" && \+ echo "${RDS_CA_BUNDLE_SHA256} /tmp/rds-combined-ca-bundle.crt" | sha256sum -c - && \+ mv /tmp/rds-combined-ca-bundle.crt /usr/local/share/ca-certificates/rds-combined-ca-bundle.crt && \+ update-ca-certificatesARG BINENV BIN=$BINdiff --git a/rust/pgapi/Cargo.toml b/rust/pgapi/Cargo.tomlindex 4457c368865b..555631fd05d7 100644--- a/rust/pgapi/Cargo.toml+++ b/rust/pgapi/Cargo.toml@@ -32,7 +32,6 @@ tokio-postgres-rustls = "0.13"tower-http = { workspace = true }tracing = { workspace = true }tracing-subscriber = { workspace = true }-webpki-roots = "1"[lints]workspace = truediff --git a/rust/pgapi/src/db.rs b/rust/pgapi/src/db.rsindex c39ac4aacca2..0edfc46c63d9 100644--- a/rust/pgapi/src/db.rs+++ b/rust/pgapi/src/db.rs@@ -20,24 +20,7 @@ impl Db {pub async fn connect(url: &str) -> Result<Self> {let mut cfg: tokio_postgres::Config = url.parse().context("parsing PGAPI_DATABASE_URL")?;cfg.ssl_mode(tokio_postgres::config::SslMode::Require);- let mut roots = rustls::RootCertStore::empty();- let native = rustls_native_certs::load_native_certs();- for err in &native.errors {- tracing::warn!(error = %err, "failed to load a native certificate");- }- for cert in native.certs {- if let Err(e) = roots.add(cert) {- tracing::warn!(error = %e, "failed to add a native certificate to root store");- }- }- if roots.is_empty() {- tracing::info!("no native certs found, falling back to webpki-roots");- roots.roots = webpki_roots::TLS_SERVER_ROOTS.to_vec();- }- let tls_cfg = rustls::ClientConfig::builder()- .with_root_certificates(roots)- .with_no_client_auth();- let tls = tokio_postgres_rustls::MakeRustlsConnect::new(tls_cfg);+ let tls = tls_connector();let mgr = Manager::from_config(cfg,tls,@@ -180,3 +163,20 @@ pub fn row_to_json(r: &tokio_postgres::Row) -> Result<Value> {}Ok(Value::Object(m))}++fn tls_connector() -> tokio_postgres_rustls::MakeRustlsConnect {+ let mut roots = rustls::RootCertStore::empty();+ let native = rustls_native_certs::load_native_certs();+ for err in &native.errors {+ tracing::warn!(error = %err, "failed to load a native certificate");+ }+ for cert in native.certs {+ if let Err(e) = roots.add(cert) {+ tracing::warn!(error = %e, "failed to add a native certificate to root store");+ }+ }+ let tls_cfg = rustls::ClientConfig::builder()+ .with_root_certificates(roots)+ .with_no_client_auth();+ tokio_postgres_rustls::MakeRustlsConnect::new(tls_cfg)+}diff --git a/rust/pgcollector/Cargo.toml b/rust/pgcollector/Cargo.tomlindex 3c1c08afa406..e1740e894f6c 100644--- a/rust/pgcollector/Cargo.toml+++ b/rust/pgcollector/Cargo.toml@@ -36,7 +36,6 @@ tokio-postgres-rustls = "0.13"toml = "0.8"tracing = { workspace = true }tracing-subscriber = { workspace = true }-webpki-roots = "1"[lints]workspace = truediff --git a/rust/pgcollector/src/pg.rs b/rust/pgcollector/src/pg.rsindex 9851119e2f7d..06fe7b47db7b 100644--- a/rust/pgcollector/src/pg.rs+++ b/rust/pgcollector/src/pg.rs@@ -31,10 +31,6 @@ pub fn tls_connector() -> tokio_postgres_rustls::MakeRustlsConnect {tracing::warn!(error = %e, "failed to add a native certificate to root store");}}- if roots.is_empty() {- tracing::info!("no native certs found, falling back to webpki-roots");- roots.roots = webpki_roots::TLS_SERVER_ROOTS.to_vec();- }let tls_cfg = rustls::ClientConfig::builder().with_root_certificates(roots).with_no_client_auth();