| 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 { |