diff options
author | Noah <33094578+coolreader18@users.noreply.github.com> | 2020-03-24 16:07:45 -0500 |
---|---|---|
committer | Noah <33094578+coolreader18@users.noreply.github.com> | 2020-03-24 21:56:04 -0500 |
commit | 354a984a7c56346361bcce90a9321acb14d93bab (patch) | |
tree | 97546a8caa4338dc3ea466038b0e512b7330d977 /openssl/src/ssl | |
parent | dbc5459d63eb55ff70531903bb6caa57366b1de3 (diff) | |
download | rust-openssl-354a984a7c56346361bcce90a9321acb14d93bab.zip |
Add SslMethod::tls_{client,server}
Diffstat (limited to 'openssl/src/ssl')
-rw-r--r-- | openssl/src/ssl/mod.rs | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/openssl/src/ssl/mod.rs b/openssl/src/ssl/mod.rs index 95c9ce1f..314f51a9 100644 --- a/openssl/src/ssl/mod.rs +++ b/openssl/src/ssl/mod.rs @@ -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! { |