Skip to content

Commit b6a1272

Browse files
committed
selected_alpn_protocol
1 parent 6af5fa8 commit b6a1272

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

stdlib/src/ssl.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1056,6 +1056,31 @@ mod _ssl {
10561056
.map(cipher_to_tuple)
10571057
}
10581058

1059+
#[pymethod]
1060+
fn selected_alpn_protocol(&self) -> Option<String> {
1061+
#[cfg(ossl102)]
1062+
{
1063+
let stream = self.stream.read();
1064+
unsafe {
1065+
let mut out: *const libc::c_uchar = std::ptr::null();
1066+
let mut outlen: libc::c_uint = 0;
1067+
1068+
sys::SSL_get0_alpn_selected(stream.ssl().as_ptr(), &mut out, &mut outlen);
1069+
1070+
if out.is_null() {
1071+
None
1072+
} else {
1073+
let slice = std::slice::from_raw_parts(out, outlen as usize);
1074+
Some(String::from_utf8_lossy(slice).into_owned())
1075+
}
1076+
}
1077+
}
1078+
#[cfg(not(ossl102))]
1079+
{
1080+
None
1081+
}
1082+
}
1083+
10591084
#[cfg(osslconf = "OPENSSL_NO_COMP")]
10601085
#[pymethod]
10611086
fn compression(&self) -> Option<&'static str> {

0 commit comments

Comments
 (0)