wire_e2e_identity/pki_env/
crl.rs

1use std::collections::HashMap;
2
3use super::{Error, Result};
4use crate::pki_env::{PkiEnvironment, hooks::HttpMethod};
5
6impl PkiEnvironment {
7    /// Fetch certificate revocation lists from the given URIs, return a map from the URLs to a DER-encoded certificate
8    /// list.
9    pub async fn fetch_crls(&self, uris: impl Iterator<Item = &str>) -> Result<HashMap<String, Vec<u8>>> {
10        let mut crls = HashMap::with_capacity(uris.size_hint().0);
11
12        for uri in uris {
13            let uri = uri.to_owned();
14            let response = self
15                .hooks
16                .http_request(HttpMethod::Get, uri.clone(), vec![], vec![])
17                .await?;
18            if !(200..300).contains(&response.status) {
19                return Err(Error::CrlFetchUnsuccessful {
20                    uri,
21                    status: response.status,
22                });
23            }
24
25            crls.insert(uri, response.body);
26        }
27
28        Ok(crls)
29    }
30}