Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
selected_alpn_protocol
  • Loading branch information
youknowone committed Oct 25, 2025
commit b6a1272b2c11ed7d64b1afdf102a4d8a5bffa744
25 changes: 25 additions & 0 deletions stdlib/src/ssl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1056,6 +1056,31 @@ mod _ssl {
.map(cipher_to_tuple)
}

#[pymethod]
fn selected_alpn_protocol(&self) -> Option<String> {
#[cfg(ossl102)]
{
let stream = self.stream.read();
unsafe {
let mut out: *const libc::c_uchar = std::ptr::null();
let mut outlen: libc::c_uint = 0;

sys::SSL_get0_alpn_selected(stream.ssl().as_ptr(), &mut out, &mut outlen);

if out.is_null() {
None
} else {
let slice = std::slice::from_raw_parts(out, outlen as usize);
Some(String::from_utf8_lossy(slice).into_owned())
}
}
}
#[cfg(not(ossl102))]
{
None
}
}

#[cfg(osslconf = "OPENSSL_NO_COMP")]
#[pymethod]
fn compression(&self) -> Option<&'static str> {
Expand Down