diff --git a/postgres-native-tls/src/lib.rs b/postgres-native-tls/src/lib.rs index 2e2f0457..ea887ed7 100644 --- a/postgres-native-tls/src/lib.rs +++ b/postgres-native-tls/src/lib.rs @@ -69,4 +69,8 @@ impl TlsStream for NativeTlsStream { fn get_mut(&mut self) -> &mut Stream { self.0.get_mut() } + + fn tls_server_end_point(&self) -> Option> { + self.0.tls_server_end_point().ok().and_then(|o| o) + } } diff --git a/postgres-native-tls/src/test.rs b/postgres-native-tls/src/test.rs index fae5fd9b..a84798d4 100644 --- a/postgres-native-tls/src/test.rs +++ b/postgres-native-tls/src/test.rs @@ -19,3 +19,20 @@ fn connect() { ).unwrap(); conn.execute("SELECT 1::VARCHAR", &[]).unwrap(); } + +#[test] +fn scram_user() { + let cert = include_bytes!("../../test/server.crt"); + let cert = Certificate::from_pem(cert).unwrap(); + + let mut builder = TlsConnector::builder(); + builder.add_root_certificate(cert); + let connector = builder.build().unwrap(); + + let handshake = NativeTls::with_connector(connector); + let conn = Connection::connect( + "postgres://scram_user:password@localhost:5433/postgres", + TlsMode::Require(&handshake), + ).unwrap(); + conn.execute("SELECT 1::VARCHAR", &[]).unwrap(); +}