Skip to content

Commit 08e8a93

Browse files
goffrieConvex, Inc.
authored andcommitted
Add SSLKEYLOGFILE support for postgres connections (#39363)
GitOrigin-RevId: 543e58d4d4b39ec220bc8d3e010973696b1e3f18
1 parent 57dd267 commit 08e8a93

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

crates/postgres/src/lib.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ use itertools::{
118118
};
119119
use rustls::{
120120
ClientConfig,
121+
KeyLogFile,
121122
RootCertStore,
122123
};
123124
use rustls_pki_types::{
@@ -333,9 +334,13 @@ impl PostgresPersistence {
333334
})?)?;
334335
}
335336
}
336-
let config = ClientConfig::builder()
337+
let mut config = ClientConfig::builder()
337338
.with_root_certificates(roots)
338339
.with_no_client_auth();
340+
if let Ok(path) = env::var("SSLKEYLOGFILE") {
341+
tracing::warn!("SSLKEYLOGFILE is set, TLS secrets will be logged to {path}");
342+
config.key_log = Arc::new(KeyLogFile::new());
343+
}
339344
let connector = MakeRustlsConnect::new(config);
340345

341346
Ok(ConvexPgPool::new(pg_config, connector))

0 commit comments

Comments
 (0)