From 912f8c4fbffa430f25d27edc8ab54b282196e0a4 Mon Sep 17 00:00:00 2001 From: Olivier 'reivilibre Date: Mon, 7 Feb 2022 13:12:06 +0000 Subject: [PATCH] Allow validating a custom name other than 'server' --- olivefs/src/main.rs | 8 ++++++++ olivefs/src/requester.rs | 3 ++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/olivefs/src/main.rs b/olivefs/src/main.rs index 5019579..b038a4c 100644 --- a/olivefs/src/main.rs +++ b/olivefs/src/main.rs @@ -48,11 +48,19 @@ async fn main() -> anyhow::Result<()> { .next() .ok_or_else(|| anyhow!("No socket addresses found for connect_to string. Perhaps no DNS resolution?"))?; + let server_name = config + .connection + .alternative_name + .as_ref() + .map(|s| s.as_str()) + .unwrap_or(config.connection.connect_to.split(':').next().unwrap()); + let requester_internal = requester::RequesterInternal::connect( &config.connection.ca_certificate, &config.connection.client_certificate, &config.connection.client_key, socket_addr, + server_name, config.connection.timeout, config.connection.keep_alive, ) diff --git a/olivefs/src/requester.rs b/olivefs/src/requester.rs index 4089cbe..dbb53cd 100644 --- a/olivefs/src/requester.rs +++ b/olivefs/src/requester.rs @@ -49,6 +49,7 @@ impl RequesterInternal { cert_path: &Path, cert_key_path: &Path, server_endpoint: SocketAddr, + server_name: &str, timeout: u32, keep_alive: u32, ) -> anyhow::Result { @@ -84,7 +85,7 @@ impl RequesterInternal { client_endpoint.set_default_client_config(client_config); let new_connection = client_endpoint - .connect(server_endpoint, "server") + .connect(server_endpoint, server_name) .unwrap() .await .unwrap();