Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose SSL(_CTX)_set1_curves_list #270

Merged
merged 1 commit into from
Sep 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions boring/src/ssl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1789,6 +1789,24 @@ impl SslContextBuilder {
unsafe { ffi::SSL_CTX_enable_ocsp_stapling(self.as_ptr()) }
}

/// Sets the context's supported curves.
//
// If the "kx-*" flags are used to set key exchange preference, then don't allow the user to
// set them here. This ensures we don't override the user's preference without telling them:
// when the flags are used, the preferences are set just before connecting or accepting.
#[cfg(not(feature = "kx-safe-default"))]
#[corresponds(SSL_CTX_set1_curves_list)]
pub fn set_curves_list(&mut self, curves: &str) -> Result<(), ErrorStack> {
let curves = CString::new(curves).unwrap();
unsafe {
cvt_0i(ffi::SSL_CTX_set1_curves_list(
self.as_ptr(),
curves.as_ptr() as *const _,
))
.map(|_| ())
}
}

/// Sets the context's supported curves.
//
// If the "kx-*" flags are used to set key exchange preference, then don't allow the user to
Expand Down Expand Up @@ -2589,11 +2607,10 @@ impl SslRef {
}

#[corresponds(SSL_set1_curves_list)]
#[cfg(feature = "kx-safe-default")]
fn set_curves_list(&mut self, curves: &str) -> Result<(), ErrorStack> {
pub fn set_curves_list(&mut self, curves: &str) -> Result<(), ErrorStack> {
let curves = CString::new(curves).unwrap();
unsafe {
cvt(ffi::SSL_set1_curves_list(
cvt_0i(ffi::SSL_set1_curves_list(
self.as_ptr(),
curves.as_ptr() as *const _,
))
Expand Down
Loading