Implement tls_server_end_point for postgres-native-tls

This commit is contained in:
Steven Fackler 2018-07-07 21:18:41 -07:00
parent 3955d26c20
commit 08df4b330f
2 changed files with 21 additions and 0 deletions

View File

@ -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<Vec<u8>> {
self.0.tls_server_end_point().ok().and_then(|o| o)
}
}

View File

@ -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();
}