Skip to content

Commit 1c51c7e

Browse files
cjpattonghedo
authored andcommitted
Add back the curve() method on SslRef
Instead of returning an `SslCurve`, just return the `u16` returned by BoringSSL.
1 parent 7078f61 commit 1c51c7e

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

boring/src/ssl/mod.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2785,6 +2785,17 @@ impl SslRef {
27852785
}
27862786
}
27872787

2788+
/// Returns the curve ID (aka group ID) used for this `SslRef`.
2789+
#[corresponds(SSL_get_curve_id)]
2790+
#[must_use]
2791+
pub fn curve(&self) -> Option<u16> {
2792+
let curve_id = unsafe { ffi::SSL_get_curve_id(self.as_ptr()) };
2793+
if curve_id == 0 {
2794+
return None;
2795+
}
2796+
Some(curve_id)
2797+
}
2798+
27882799
/// Returns an `ErrorCode` value for the most recent operation on this `SslRef`.
27892800
#[corresponds(SSL_get_error)]
27902801
#[must_use]

boring/src/ssl/test/mod.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -951,6 +951,15 @@ fn sni_callback_swapped_ctx() {
951951
assert!(CALLED_BACK.load(Ordering::SeqCst));
952952
}
953953

954+
#[test]
955+
fn get_curve() {
956+
let server = Server::builder().build();
957+
let client = server.client_with_root_ca();
958+
let client_stream = client.connect();
959+
let curve = client_stream.ssl().curve();
960+
assert!(curve.is_some());
961+
}
962+
954963
#[test]
955964
fn test_get_ciphers() {
956965
let ctx_builder = SslContext::builder(SslMethod::tls()).unwrap();

0 commit comments

Comments
 (0)