Unverified Commit ef369f82 authored by Steven Fackler's avatar Steven Fackler Committed by GitHub
Browse files

Merge pull request #1249 from coolreader18/more-ssl-method

Add SslMethod::tls_{client,server}
parents 7c4986aa 354a984a
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -1089,6 +1089,10 @@ cfg_if! {
            pub fn TLS_method() -> *const SSL_METHOD;

            pub fn DTLS_method() -> *const SSL_METHOD;

            pub fn TLS_server_method() -> *const SSL_METHOD;

            pub fn TLS_client_method() -> *const SSL_METHOD;
        }
    } else {
        extern "C" {
@@ -1097,6 +1101,10 @@ cfg_if! {

            pub fn SSLv23_method() -> *const SSL_METHOD;

            pub fn SSLv23_client_method() -> *const SSL_METHOD;

            pub fn SSLv23_server_method() -> *const SSL_METHOD;

            pub fn TLSv1_method() -> *const SSL_METHOD;

            pub fn TLSv1_1_method() -> *const SSL_METHOD;
+21 −2
Original line number Diff line number Diff line
@@ -323,6 +323,22 @@ impl SslMethod {
        unsafe { SslMethod(DTLS_method()) }
    }

    /// Support all versions of the TLS protocol, explicitly as a client.
    ///
    /// This corresponds to `TLS_client_method` on OpenSSL 1.1.0 and
    /// `SSLv23_client_method` on OpenSSL 1.0.x.
    pub fn tls_client() -> SslMethod {
        unsafe { SslMethod(TLS_client_method()) }
    }

    /// Support all versions of the TLS protocol, explicitly as a server.
    ///
    /// This corresponds to `TLS_server_method` on OpenSSL 1.1.0 and
    /// `SSLv23_server_method` on OpenSSL 1.0.x.
    pub fn tls_server() -> SslMethod {
        unsafe { SslMethod(TLS_server_method()) }
    }

    /// Constructs an `SslMethod` from a pointer to the underlying OpenSSL value.
    pub unsafe fn from_ptr(ptr: *const ffi::SSL_METHOD) -> SslMethod {
        SslMethod(ptr)
@@ -3899,9 +3915,12 @@ cfg_if! {

cfg_if! {
    if #[cfg(any(ossl110, libressl291))] {
        use ffi::{TLS_method, DTLS_method};
        use ffi::{TLS_method, DTLS_method, TLS_client_method, TLS_server_method};
    } else {
        use ffi::{SSLv23_method as TLS_method, DTLSv1_method as DTLS_method};
        use ffi::{
            SSLv23_method as TLS_method, DTLSv1_method as DTLS_method, SSLv23_client_method as TLS_client_method,
            SSLv23_server_method as TLS_server_method,
        };
    }
}
cfg_if! {