diff --git a/openssl/src/ssl/connector.rs b/openssl/src/ssl/connector.rs index bc0bac9216abbe13dc117f66e056c87520df2b5a..644a0488b4761ef7b27cd571cbbb5e8086ff0420 100644 --- a/openssl/src/ssl/connector.rs +++ b/openssl/src/ssl/connector.rs @@ -168,13 +168,10 @@ impl ConnectConfiguration { self.verify_hostname = verify_hostname; } - /// Initiates a client-side TLS session on a stream. + /// Returns an `Ssl` configured to connect to the provided domain. /// /// The domain is used for SNI and hostname verification if enabled. - pub fn connect(mut self, domain: &str, stream: S) -> Result, HandshakeError> - where - S: Read + Write, - { + pub fn into_ssl(mut self, domain: &str) -> Result { if self.sni { self.ssl.set_hostname(domain)?; } @@ -183,7 +180,17 @@ impl ConnectConfiguration { setup_verify_hostname(&mut self.ssl, domain)?; } - self.ssl.connect(stream) + Ok(self.ssl) + } + + /// Initiates a client-side TLS session on a stream. + /// + /// The domain is used for SNI and hostname verification if enabled. + pub fn connect(self, domain: &str, stream: S) -> Result, HandshakeError> + where + S: Read + Write, + { + self.into_ssl(domain)?.connect(stream) } }