Add SslRef::curve_name()

This commit is contained in:
Alessandro Ghedini 2025-09-30 16:29:18 +01:00 committed by Alessandro Ghedini
parent 4ce1308e1c
commit b3521e5523
2 changed files with 18 additions and 0 deletions

View File

@ -2780,6 +2780,22 @@ impl SslRef {
Some(curve_id)
}
/// Returns the curve name used for this `SslRef`.
#[corresponds(SSL_get_curve_name)]
#[must_use]
pub fn curve_name(&self) -> Option<&'static str> {
let curve_id = self.curve()?;
unsafe {
let ptr = ffi::SSL_get_curve_name(curve_id);
if ptr.is_null() {
return None;
}
CStr::from_ptr(ptr).to_str().ok()
}
}
/// Returns an `ErrorCode` value for the most recent operation on this `SslRef`.
#[corresponds(SSL_get_error)]
#[must_use]

View File

@ -958,6 +958,8 @@ fn get_curve() {
let client_stream = client.connect();
let curve = client_stream.ssl().curve();
assert!(curve.is_some());
let curve_name = client_stream.ssl().curve_name();
assert!(curve_name.is_some());
}
#[test]