(store_name: PyUtf8StrRef, vm: &VirtualMachine)
| 5024 | #[cfg(windows)] |
| 5025 | #[pyfunction] |
| 5026 | fn enum_crls(store_name: PyUtf8StrRef, vm: &VirtualMachine) -> PyResult<Vec<PyObjectRef>> { |
| 5027 | use windows_sys::Win32::Security::Cryptography::{ |
| 5028 | CRL_CONTEXT, CertCloseStore, CertEnumCRLsInStore, CertOpenSystemStoreW, |
| 5029 | X509_ASN_ENCODING, |
| 5030 | }; |
| 5031 | |
| 5032 | let store_name_str = store_name.as_str(); |
| 5033 | let store_name_wide: Vec<u16> = store_name_str |
| 5034 | .encode_utf16() |
| 5035 | .chain(core::iter::once(0)) |
| 5036 | .collect(); |
| 5037 | |
| 5038 | // Open system store |
| 5039 | let store = unsafe { CertOpenSystemStoreW(0, store_name_wide.as_ptr()) }; |
| 5040 | |
| 5041 | if store.is_null() { |
| 5042 | return Err(vm.new_os_error(format!( |
| 5043 | "failed to open certificate store {:?}", |
| 5044 | store_name_str |
| 5045 | ))); |
| 5046 | } |
| 5047 | |
| 5048 | let mut result = Vec::new(); |
| 5049 | |
| 5050 | let mut crl_context: *const CRL_CONTEXT = core::ptr::null(); |
| 5051 | loop { |
| 5052 | crl_context = unsafe { CertEnumCRLsInStore(store, crl_context) }; |
| 5053 | if crl_context.is_null() { |
| 5054 | break; |
| 5055 | } |
| 5056 | |
| 5057 | let crl = unsafe { &*crl_context }; |
| 5058 | let crl_bytes = |
| 5059 | unsafe { core::slice::from_raw_parts(crl.pbCrlEncoded, crl.cbCrlEncoded as usize) }; |
| 5060 | |
| 5061 | let enc_type = if crl.dwCertEncodingType == X509_ASN_ENCODING { |
| 5062 | vm.new_pyobj("x509_asn") |
| 5063 | } else { |
| 5064 | vm.new_pyobj(crl.dwCertEncodingType) |
| 5065 | }; |
| 5066 | |
| 5067 | result.push( |
| 5068 | vm.new_tuple((vm.ctx.new_bytes(crl_bytes.to_vec()), enc_type)) |
| 5069 | .into(), |
| 5070 | ); |
| 5071 | } |
| 5072 | |
| 5073 | unsafe { CertCloseStore(store, 0) }; |
| 5074 | |
| 5075 | Ok(result) |
| 5076 | } |
| 5077 | |
| 5078 | // Certificate type for SSL module (pure Rust implementation) |
| 5079 | #[pyattr] |
nothing calls this directly
no test coverage detected