Skip to content

Commit 4686ccc

Browse files
committed
get_unverified_chain
1 parent 2000932 commit 4686ccc

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

stdlib/src/ssl.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,6 +1028,19 @@ mod _ssl {
10281028
.transpose()
10291029
}
10301030

1031+
#[pymethod]
1032+
fn get_unverified_chain(&self, vm: &VirtualMachine) -> Option<PyObjectRef> {
1033+
let stream = self.stream.read();
1034+
let chain = stream.ssl().peer_cert_chain()?;
1035+
1036+
let certs: Vec<PyObjectRef> = chain
1037+
.iter()
1038+
.filter_map(|cert| cert.to_der().ok().map(|der| vm.ctx.new_bytes(der).into()))
1039+
.collect();
1040+
1041+
Some(vm.ctx.new_list(certs).into())
1042+
}
1043+
10311044
#[pymethod]
10321045
fn version(&self) -> Option<&'static str> {
10331046
let v = self.stream.read().ssl().version_str();

0 commit comments

Comments
 (0)