Skip to content

Commit

Permalink
set alpn when direct ssl negotiation is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
fakeshadow committed Sep 29, 2024
1 parent e7f1e27 commit 3cfde80
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions postgres/src/driver/tls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ use xitca_tls::rustls::{
ClientConfig, ClientConnection, DigitallySignedStruct, RootCertStore, TlsStream,
};

use crate::{config::Config, error::Error};
use crate::{
config::{Config, SslNegotiation},
error::Error,
};

pub(super) async fn connect_tls<Io>(
io: Io,
Expand All @@ -21,7 +24,12 @@ where
Io: AsyncIo,
{
let name = ServerName::try_from(host).map_err(|_| Error::todo())?.to_owned();
let config = dangerous_config(Vec::new());
let mut config = dangerous_config(Vec::new());

if cfg.get_ssl_negotiation() == SslNegotiation::Direct {
config.alpn_protocols = vec![b"postgresql".to_vec()];
}

let config = Arc::new(config);
let session = ClientConnection::new(config, name).map_err(|_| Error::todo())?;

Expand Down

0 comments on commit 3cfde80

Please sign in to comment.