Commit ac3dec7c authored by Steven Fackler's avatar Steven Fackler
Browse files

Allow SslConnector to return a raw Ssl

parent 455a1e36
Loading
Loading
Loading
Loading
+13 −6
Original line number Diff line number Diff line
@@ -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<S>(mut self, domain: &str, stream: S) -> Result<SslStream<S>, HandshakeError<S>>
    where
        S: Read + Write,
    {
    pub fn into_ssl(mut self, domain: &str) -> Result<Ssl, ErrorStack> {
        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<S>(self, domain: &str, stream: S) -> Result<SslStream<S>, HandshakeError<S>>
    where
        S: Read + Write,
    {
        self.into_ssl(domain)?.connect(stream)
    }
}