Skip to content

Commit

Permalink
Merge pull request #2358 from alex/expose-dlts
Browse files Browse the repository at this point in the history
Expose `SslMethod::{dtls_client,dtls_server}`
  • Loading branch information
alex authored Feb 1, 2025
2 parents 16ca5b2 + 5ecb31d commit 1aff280
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
4 changes: 4 additions & 0 deletions openssl-sys/src/handwritten/ssl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down
16 changes: 15 additions & 1 deletion openssl/src/ssl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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_server_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
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 1aff280

Please sign in to comment.