| 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)] |