aboutsummaryrefslogtreecommitdiff
path: root/openssl/src/ssl/mod.rs
diff options
context:
space:
mode:
authorSteven Fackler <[email protected]>2018-06-17 15:47:00 -0700
committerGitHub <[email protected]>2018-06-17 15:47:00 -0700
commit6440ee04ef21e2e08e11017776f0d1543f5ce6bc (patch)
tree956606e02b949da9387730dba36523f0ff2745a2 /openssl/src/ssl/mod.rs
parentMerge pull request #946 from sfackler/libressl-accessors (diff)
parentDisable TLSv1.3 for psk_ciphers test (diff)
downloadrust-openssl-6440ee04ef21e2e08e11017776f0d1543f5ce6bc.tar.xz
rust-openssl-6440ee04ef21e2e08e11017776f0d1543f5ce6bc.zip
Merge pull request #943 from lolzballs/master
Add wrapper for SSL_CTX_set_psk_server_callback
Diffstat (limited to 'openssl/src/ssl/mod.rs')
-rw-r--r--openssl/src/ssl/mod.rs37
1 files changed, 36 insertions, 1 deletions
diff --git a/openssl/src/ssl/mod.rs b/openssl/src/ssl/mod.rs
index cd808829..1feb3ca6 100644
--- a/openssl/src/ssl/mod.rs
+++ b/openssl/src/ssl/mod.rs
@@ -1252,6 +1252,21 @@ impl SslContextBuilder {
///
/// [`SSL_CTX_set_psk_client_callback`]: https://www.openssl.org/docs/man1.0.2/ssl/SSL_CTX_set_psk_client_callback.html
#[cfg(not(osslconf = "OPENSSL_NO_PSK"))]
+ pub fn set_psk_client_callback<F>(&mut self, callback: F)
+ where
+ F: Fn(&mut SslRef, Option<&[u8]>, &mut [u8], &mut [u8]) -> Result<usize, ErrorStack>
+ + 'static
+ + Sync
+ + Send,
+ {
+ unsafe {
+ self.set_ex_data(SslContext::cached_ex_index::<F>(), callback);
+ ffi::SSL_CTX_set_psk_client_callback(self.as_ptr(), Some(raw_client_psk::<F>));
+ }
+ }
+
+ #[deprecated(since = "0.10.10", note = "renamed to `set_psk_client_callback`")]
+ #[cfg(not(osslconf = "OPENSSL_NO_PSK"))]
pub fn set_psk_callback<F>(&mut self, callback: F)
where
F: Fn(&mut SslRef, Option<&[u8]>, &mut [u8], &mut [u8]) -> Result<usize, ErrorStack>
@@ -1259,9 +1274,29 @@ impl SslContextBuilder {
+ Sync
+ Send,
{
+ self.set_psk_client_callback(callback)
+ }
+
+ /// Sets the callback for providing an identity and pre-shared key for a TLS-PSK server.
+ ///
+ /// The callback will be called with the SSL context, an identity provided by the client,
+ /// and, a mutable slice for the pre-shared key bytes. The callback returns the number of
+ /// bytes in the pre-shared key.
+ ///
+ /// This corresponds to [`SSL_CTX_set_psk_server_callback`].
+ ///
+ /// [`SSL_CTX_set_psk_server_callback`]: https://www.openssl.org/docs/man1.0.2/ssl/SSL_CTX_set_psk_server_callback.html
+ #[cfg(not(osslconf = "OPENSSL_NO_PSK"))]
+ pub fn set_psk_server_callback<F>(&mut self, callback: F)
+ where
+ F: Fn(&mut SslRef, Option<&[u8]>, &mut [u8]) -> Result<usize, ErrorStack>
+ + 'static
+ + Sync
+ + Send,
+ {
unsafe {
self.set_ex_data(SslContext::cached_ex_index::<F>(), callback);
- ffi::SSL_CTX_set_psk_client_callback(self.as_ptr(), Some(raw_psk::<F>));
+ ffi::SSL_CTX_set_psk_server_callback(self.as_ptr(), Some(raw_server_psk::<F>));
}
}