summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteven Fackler <sfackler@gmail.com>2020-12-23 20:35:05 -0500
committerSteven Fackler <sfackler@gmail.com>2020-12-23 20:56:42 -0500
commitac3dec7c402ccd7f3a79bf9a4ba22b6cbc8f2759 (patch)
tree6bdc2d4a5ed78a13689f2c7bd02b129ee0f9cc02
parent455a1e362eda44584e4962ee98fe7fc1fd0d257d (diff)
downloadrust-openssl-ac3dec7c402ccd7f3a79bf9a4ba22b6cbc8f2759.zip
Allow SslConnector to return a raw Ssl
-rw-r--r--openssl/src/ssl/connector.rs19
1 files changed, 13 insertions, 6 deletions
diff --git a/openssl/src/ssl/connector.rs b/openssl/src/ssl/connector.rs
index bc0bac92..644a0488 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<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)
}
}