From 4830f5bb93dafeeeddf32bf41dda83e2560f3d49 Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Sat, 1 Feb 2025 11:13:16 -0800 Subject: [PATCH] Expose `SslMethod::{dtls_client,dtls_server}` --- openssl-sys/src/handwritten/ssl.rs | 4 ++++ openssl/src/ssl/mod.rs | 16 +++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/openssl-sys/src/handwritten/ssl.rs b/openssl-sys/src/handwritten/ssl.rs index b86a54cbe..163c75aed 100644 --- a/openssl-sys/src/handwritten/ssl.rs +++ b/openssl-sys/src/handwritten/ssl.rs @@ -701,6 +701,10 @@ cfg_if! { pub fn TLS_server_method() -> *const SSL_METHOD; pub fn TLS_client_method() -> *const SSL_METHOD; + + pub fn DTLS_server_method() -> *const SSL_METHOD; + + pub fn DTLS_client_method() -> *const SSL_METHOD; } } else { extern "C" { diff --git a/openssl/src/ssl/mod.rs b/openssl/src/ssl/mod.rs index c341642a2..aac726a69 100644 --- a/openssl/src/ssl/mod.rs +++ b/openssl/src/ssl/mod.rs @@ -364,6 +364,20 @@ impl SslMethod { unsafe { SslMethod(TLS_server_method()) } } + /// Support all versions of the DTLS protocol, explicitly as a client. + #[corresponds(DTLS_client_method)] + #[cfg(any(boringssl, ossl110, libressl291))] + pub fn dtls_client() -> SslMethod { + unsafe { SslMethod(DTLS_client_method()) } + } + + /// Support all versions of the DTLS protocol, explicitly as a server. + #[corresponds(DTLS_method)] + #[cfg(any(boringssl, ossl110, libressl291))] + pub fn dtls_server() -> SslMethod { + unsafe { SslMethod(DTLS_server_method()) } + } + /// Constructs an `SslMethod` from a pointer to the underlying OpenSSL value. /// /// # Safety @@ -4288,7 +4302,7 @@ cfg_if! { } cfg_if! { if #[cfg(any(boringssl, ossl110, libressl291))] { - use ffi::{TLS_method, DTLS_method, TLS_client_method, TLS_server_method}; + use ffi::{TLS_method, DTLS_method, TLS_client_method, TLS_server_method, DTLS_server_method, DTLS_client_method}; } else { use ffi::{ SSLv23_method as TLS_method, DTLSv1_method as DTLS_method, SSLv23_client_method as TLS_client_method,