aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteven Fackler <[email protected]>2018-05-12 16:50:50 +0100
committerSteven Fackler <[email protected]>2018-05-12 16:50:50 +0100
commitff2c7ffefd4645ce6a160d55428567efee37aa40 (patch)
tree4d9b6cd6336fa65c7ff1ad3e5cd717fb3e0e4fdd
parentMerge pull request #916 from sfackler/ssl-callback-cleanup (diff)
downloadrust-openssl-ff2c7ffefd4645ce6a160d55428567efee37aa40.tar.xz
rust-openssl-ff2c7ffefd4645ce6a160d55428567efee37aa40.zip
Merge Ssl impl blocks
-rw-r--r--openssl/src/ssl/mod.rs112
1 files changed, 55 insertions, 57 deletions
diff --git a/openssl/src/ssl/mod.rs b/openssl/src/ssl/mod.rs
index 747b7a84..8dc605ed 100644
--- a/openssl/src/ssl/mod.rs
+++ b/openssl/src/ssl/mod.rs
@@ -1902,6 +1902,15 @@ foreign_type! {
pub struct SslRef;
}
+unsafe impl Sync for Ssl {}
+unsafe impl Send for Ssl {}
+
+impl fmt::Debug for Ssl {
+ fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
+ fmt::Debug::fmt(&**self, fmt)
+ }
+}
+
impl Ssl {
/// Returns a new extra data index.
///
@@ -1936,6 +1945,52 @@ impl Ssl {
Index::from_raw(idx)
}
}
+
+ /// Creates a new `Ssl`.
+ ///
+ /// This corresponds to [`SSL_new`].
+ ///
+ /// [`SSL_new`]: https://www.openssl.org/docs/man1.0.2/ssl/SSL_new.html
+ pub fn new(ctx: &SslContext) -> Result<Ssl, ErrorStack> {
+ unsafe {
+ let ssl = cvt_p(ffi::SSL_new(ctx.as_ptr()))?;
+ Ok(Ssl::from_ptr(ssl))
+ }
+ }
+
+ /// Initiates a client-side TLS handshake.
+ ///
+ /// This corresponds to [`SSL_connect`].
+ ///
+ /// # Warning
+ ///
+ /// OpenSSL's default configuration is insecure. It is highly recommended to use
+ /// `SslConnector` rather than `Ssl` directly, as it manages that configuration.
+ ///
+ /// [`SSL_connect`]: https://www.openssl.org/docs/manmaster/man3/SSL_connect.html
+ pub fn connect<S>(self, stream: S) -> Result<SslStream<S>, HandshakeError<S>>
+ where
+ S: Read + Write,
+ {
+ SslStreamBuilder::new(self, stream).connect()
+ }
+
+ /// Initiates a server-side TLS handshake.
+ ///
+ /// This corresponds to [`SSL_accept`].
+ ///
+ /// # Warning
+ ///
+ /// OpenSSL's default configuration is insecure. It is highly recommended to use
+ /// `SslAcceptor` rather than `Ssl` directly, as it manages that configuration.
+ ///
+ /// [`SSL_accept`]: https://www.openssl.org/docs/manmaster/man3/SSL_accept.html
+ pub fn accept<S>(self, stream: S) -> Result<SslStream<S>, HandshakeError<S>>
+ where
+ S: Read + Write,
+ {
+ SslStreamBuilder::new(self, stream).accept()
+ }
}
impl fmt::Debug for SslRef {
@@ -2541,63 +2596,6 @@ impl SslRef {
}
}
-unsafe impl Sync for Ssl {}
-unsafe impl Send for Ssl {}
-
-impl fmt::Debug for Ssl {
- fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
- fmt::Debug::fmt(&**self, fmt)
- }
-}
-
-impl Ssl {
- /// Creates a new `Ssl`.
- ///
- /// This corresponds to [`SSL_new`].
- ///
- /// [`SSL_new`]: https://www.openssl.org/docs/man1.0.2/ssl/SSL_new.html
- pub fn new(ctx: &SslContext) -> Result<Ssl, ErrorStack> {
- unsafe {
- let ssl = cvt_p(ffi::SSL_new(ctx.as_ptr()))?;
- Ok(Ssl::from_ptr(ssl))
- }
- }
-
- /// Initiates a client-side TLS handshake.
- ///
- /// This corresponds to [`SSL_connect`].
- ///
- /// # Warning
- ///
- /// OpenSSL's default configuration is insecure. It is highly recommended to use
- /// `SslConnector` rather than `Ssl` directly, as it manages that configuration.
- ///
- /// [`SSL_connect`]: https://www.openssl.org/docs/manmaster/man3/SSL_connect.html
- pub fn connect<S>(self, stream: S) -> Result<SslStream<S>, HandshakeError<S>>
- where
- S: Read + Write,
- {
- SslStreamBuilder::new(self, stream).connect()
- }
-
- /// Initiates a server-side TLS handshake.
- ///
- /// This corresponds to [`SSL_accept`].
- ///
- /// # Warning
- ///
- /// OpenSSL's default configuration is insecure. It is highly recommended to use
- /// `SslAcceptor` rather than `Ssl` directly, as it manages that configuration.
- ///
- /// [`SSL_accept`]: https://www.openssl.org/docs/manmaster/man3/SSL_accept.html
- pub fn accept<S>(self, stream: S) -> Result<SslStream<S>, HandshakeError<S>>
- where
- S: Read + Write,
- {
- SslStreamBuilder::new(self, stream).accept()
- }
-}
-
/// An SSL stream midway through the handshake process.
#[derive(Debug)]
pub struct MidHandshakeSslStream<S> {