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

Method try_parse_crl

crates/stdlib/src/ssl.rs:2131–2149  ·  view source on GitHub ↗

Helper: Try to parse data as CRL (PEM or DER format)

(
            &self,
            data: &[u8],
        )

Source from the content-addressed store, hash-verified

2129
2130 /// Helper: Try to parse data as CRL (PEM or DER format)
2131 fn try_parse_crl(
2132 &self,
2133 data: &[u8],
2134 ) -> Result<CertificateRevocationListDer<'static>, String> {
2135 // Try PEM format first
2136 let mut cursor = std::io::Cursor::new(data);
2137 let mut crl_iter = rustls_pemfile::crls(&mut cursor);
2138 if let Some(Ok(crl)) = crl_iter.next() {
2139 return Ok(crl);
2140 }
2141
2142 // Try DER format
2143 // Basic validation: CRL should start with SEQUENCE tag (0x30)
2144 if !data.is_empty() && data[0] == 0x30 {
2145 return Ok(CertificateRevocationListDer::from(data.to_vec()));
2146 }
2147
2148 Err("Not a valid CRL file".to_string())
2149 }
2150
2151 /// Helper: Load CRL from file
2152 fn load_crl_from_file(

Callers 1

load_crl_from_fileMethod · 0.80

Calls 6

newFunction · 0.85
to_vecMethod · 0.80
to_stringMethod · 0.80
ErrClass · 0.50
nextMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected