Skip to content

Commit

Permalink
support connecting to server with domain and self-signed certificate
Browse files Browse the repository at this point in the history
  • Loading branch information
neevek committed Jun 8, 2024
1 parent 1a987af commit 848abd7
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -422,23 +422,23 @@ impl Client {

self.post_tunnel_log(format!("will use cipher: {}", self.config.cipher).as_str());

if !Self::is_ip_addr(&self.config.server_addr) {
let domain = match self.config.server_addr.rfind(':') {
Some(colon_index) => self.config.server_addr[0..colon_index].to_string(),
None => self.config.server_addr.to_string(),
};

let client_config = rustls::ClientConfig::builder()
.with_cipher_suites(&[cipher])
.with_safe_default_kx_groups()
.with_safe_default_protocol_versions()?
.with_custom_certificate_verifier(Arc::new(Verifier::new()))
.with_no_client_auth();

return Ok((client_config, domain));
}

if self.config.cert_path.is_empty() {
if !Self::is_ip_addr(&self.config.server_addr) {
let domain = match self.config.server_addr.rfind(':') {
Some(colon_index) => self.config.server_addr[0..colon_index].to_string(),
None => self.config.server_addr.to_string(),
};

let client_config = rustls::ClientConfig::builder()
.with_cipher_suites(&[cipher])
.with_safe_default_kx_groups()
.with_safe_default_protocol_versions()?
.with_custom_certificate_verifier(Arc::new(Verifier::new()))
.with_no_client_auth();

return Ok((client_config, domain));
}

let client_config = rustls::ClientConfig::builder()
.with_cipher_suites(&[cipher])
.with_safe_default_kx_groups()
Expand Down

0 comments on commit 848abd7

Please sign in to comment.