Add back the `curve()` method on `SslRef`

Instead of returning an `SslCurve`, just return the `u16` returned by
BoringSSL.
This commit is contained in:
Christopher Patton 2025-09-30 07:51:37 -07:00 committed by Alessandro Ghedini
parent 7078f61077
commit 1c51c7ee3b
2 changed files with 20 additions and 0 deletions

View File

@ -2785,6 +2785,17 @@ impl SslRef {
} }
} }
/// Returns the curve ID (aka group ID) used for this `SslRef`.
#[corresponds(SSL_get_curve_id)]
#[must_use]
pub fn curve(&self) -> Option<u16> {
let curve_id = unsafe { ffi::SSL_get_curve_id(self.as_ptr()) };
if curve_id == 0 {
return None;
}
Some(curve_id)
}
/// Returns an `ErrorCode` value for the most recent operation on this `SslRef`. /// Returns an `ErrorCode` value for the most recent operation on this `SslRef`.
#[corresponds(SSL_get_error)] #[corresponds(SSL_get_error)]
#[must_use] #[must_use]

View File

@ -951,6 +951,15 @@ fn sni_callback_swapped_ctx() {
assert!(CALLED_BACK.load(Ordering::SeqCst)); assert!(CALLED_BACK.load(Ordering::SeqCst));
} }
#[test]
fn get_curve() {
let server = Server::builder().build();
let client = server.client_with_root_ca();
let client_stream = client.connect();
let curve = client_stream.ssl().curve();
assert!(curve.is_some());
}
#[test] #[test]
fn test_get_ciphers() { fn test_get_ciphers() {
let ctx_builder = SslContext::builder(SslMethod::tls()).unwrap(); let ctx_builder = SslContext::builder(SslMethod::tls()).unwrap();