diff --git a/crates/sip-core/Cargo.toml b/crates/sip-core/Cargo.toml index 0813c74..96e007a 100644 --- a/crates/sip-core/Cargo.toml +++ b/crates/sip-core/Cargo.toml @@ -39,9 +39,11 @@ trust-dns-resolver = "0.23" multimap = "0.10" nom = "7" -tokio-rustls = { version = "0.26", optional = true } +tokio-rustls = { version = "0.26", optional = true, default-features = false } +rustls-pki-types = { version = "1", features = ["std"], optional = true } tokio-native-tls = { version = "0.3", optional = true } + [features] -tls-rustls = ["dep:tokio-rustls"] +tls-rustls = ["dep:tokio-rustls", "dep:rustls-pki-types"] tls-native-tls = ["dep:tokio-native-tls"] diff --git a/crates/sip-core/src/transport/rustls.rs b/crates/sip-core/src/transport/rustls.rs index 2e1eea9..d86084c 100644 --- a/crates/sip-core/src/transport/rustls.rs +++ b/crates/sip-core/src/transport/rustls.rs @@ -1,12 +1,12 @@ use super::streaming::{ StreamingFactory, StreamingListener, StreamingListenerBuilder, StreamingTransport, }; +use rustls_pki_types::{IpAddr, ServerName}; use sip_types::{host::Host, uri::UriInfo}; use std::convert::TryFrom; use std::io; use std::net::SocketAddr; use tokio::net::{TcpListener, TcpStream, ToSocketAddrs}; -use tokio_rustls::rustls::ServerName; use tokio_rustls::{TlsAcceptor, TlsConnector, TlsStream}; // ==== Connector @@ -22,9 +22,10 @@ impl StreamingFactory for TlsConnector { ) -> io::Result { let server_name = match uri_info.host_port.host { Host::Name(ref name) => ServerName::try_from(name.as_str()) - .map_err(|e| io::Error::new(io::ErrorKind::Other, e))?, - Host::IP4(ip) => ServerName::IpAddress(ip.into()), - Host::IP6(ip) => ServerName::IpAddress(ip.into()), + .map_err(|e| io::Error::new(io::ErrorKind::Other, e))? + .to_owned(), + Host::IP4(ip) => ServerName::IpAddress(IpAddr::V4(ip.into())), + Host::IP6(ip) => ServerName::IpAddress(IpAddr::V6(ip.into())), }; let stream = TcpStream::connect(addr).await?;