use oci_client::client::{Certificate, CertificateEncoding};
pub(super) async fn root_certificates() -> Vec<Certificate> {
let loaded = tokio::task::spawn_blocking(rustls_native_certs::load_native_certs)
.await
.inspect_err(|e| tracing::warn!("could not read the system certificate store: {e}"))
.unwrap_or_default();
for error in &loaded.errors {
tracing::debug!("skipped part of the system certificate store: {error}");
}
loaded
.certs
.into_iter()
.filter(|cert| webpki::anchor_from_trusted_cert(cert).is_ok())
.map(|cert| Certificate {
encoding: CertificateEncoding::Der,
data: cert.to_vec(),
})
.collect()
}