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

Method get_ca_certs

crates/stdlib/src/openssl.rs:1557–1581  ·  view source on GitHub ↗
(
            &self,
            args: GetCertArgs,
            vm: &VirtualMachine,
        )

Source from the content-addressed store, hash-verified

1555
1556 #[pymethod]
1557 fn get_ca_certs(
1558 &self,
1559 args: GetCertArgs,
1560 vm: &VirtualMachine,
1561 ) -> PyResult<Vec<PyObjectRef>> {
1562 let binary_form = args.binary_form.unwrap_or(false);
1563 let ctx = self.ctx();
1564 #[cfg(ossl300)]
1565 let certs = ctx.cert_store().all_certificates();
1566 #[cfg(not(ossl300))]
1567 let certs = ctx.cert_store().objects().iter().filter_map(|x| x.x509());
1568
1569 // Filter to only include CA certificates (Basic Constraints: CA=TRUE)
1570 let certs = certs
1571 .into_iter()
1572 .filter(|cert| {
1573 unsafe {
1574 // X509_check_ca() returns 1 for CA certificates
1575 X509_check_ca(cert.as_ptr()) == 1
1576 }
1577 })
1578 .map(|ref cert| cert_to_py(vm, cert, binary_form))
1579 .collect::<Result<Vec<_>, _>>()?;
1580 Ok(certs)
1581 }
1582
1583 #[pymethod]
1584 fn cert_store_stats(&self, vm: &VirtualMachine) -> PyResult {

Callers

nothing calls this directly

Calls 7

cert_to_pyFunction · 0.85
ctxMethod · 0.45
iterMethod · 0.45
mapMethod · 0.45
filterMethod · 0.45
into_iterMethod · 0.45
as_ptrMethod · 0.45

Tested by

no test coverage detected