Visitar URL original
Allow SslConnector to return a raw Ssl · rust-openssl/rust-openssl@ac3dec7 · GitHub
Skip to content

Commit ac3dec7

Browse files
committed
Allow SslConnector to return a raw Ssl
1 parent 455a1e3 commit ac3dec7

1 file changed

Lines changed: 13 additions & 6 deletions

File tree

‎openssl/src/ssl/connector.rs‎

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -168,13 +168,10 @@ impl ConnectConfiguration {
168168
self.verify_hostname = verify_hostname;
169169
}
170170

171-
/// Initiates a client-side TLS session on a stream.
171+
/// Returns an `Ssl` configured to connect to the provided domain.
172172
///
173173
/// The domain is used for SNI and hostname verification if enabled.
174-
pub fn connect<S>(mut self, domain: &str, stream: S) -> Result<SslStream<S>, HandshakeError<S>>
175-
where
176-
S: Read + Write,
177-
{
174+
pub fn into_ssl(mut self, domain: &str) -> Result<Ssl, ErrorStack> {
178175
if self.sni {
179176
self.ssl.set_hostname(domain)?;
180177
}
@@ -183,7 +180,17 @@ impl ConnectConfiguration {
183180
setup_verify_hostname(&mut self.ssl, domain)?;
184181
}
185182

186-
self.ssl.connect(stream)
183+
Ok(self.ssl)
184+
}
185+
186+
/// Initiates a client-side TLS session on a stream.
187+
///
188+
/// The domain is used for SNI and hostname verification if enabled.
189+
pub fn connect<S>(self, domain: &str, stream: S) -> Result<SslStream<S>, HandshakeError<S>>
190+
where
191+
S: Read + Write,
192+
{
193+
self.into_ssl(domain)?.connect(stream)
187194
}
188195
}
189196

0 commit comments

Comments
 (0)