MCPcopy Index your code
hub / github.com/RustPython/RustPython / PEM_cert_to_DER_cert

Function PEM_cert_to_DER_cert

crates/stdlib/src/ssl.rs:4956–4966  ·  view source on GitHub ↗
(pem_cert: PyUtf8StrRef, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

4954
4955 #[pyfunction]
4956 fn PEM_cert_to_DER_cert(pem_cert: PyUtf8StrRef, vm: &VirtualMachine) -> PyResult<PyBytesRef> {
4957 // Parse PEM format
4958 let mut cursor = std::io::Cursor::new(pem_cert.as_bytes());
4959 let mut certs = rustls_pemfile::certs(&mut cursor);
4960
4961 if let Some(Ok(cert)) = certs.next() {
4962 Ok(vm.ctx.new_bytes(cert.to_vec()))
4963 } else {
4964 Err(vm.new_value_error("Failed to parse PEM certificate"))
4965 }
4966 }
4967
4968 // Windows-specific certificate store enumeration functions
4969 #[cfg(windows)]

Callers

nothing calls this directly

Calls 6

newFunction · 0.85
to_vecMethod · 0.80
ErrClass · 0.50
as_bytesMethod · 0.45
nextMethod · 0.45
new_bytesMethod · 0.45

Tested by

no test coverage detected