mozilla_root_ca/
rustls.rs1use crate::*;
2
3use core::mem;
4
5use rustls_pki_types::{CertificateDer, Der};
6
7pub static RUSTLS_DER_LIST: [Der<'static>; DER_LIST_LEN] = {
8 let mut list = [const { Der::from_slice(b"") }; DER_LIST_LEN];
9
10 let mut i = 0;
11 while i < DER_LIST_LEN {
12 mem::forget(mem::replace(&mut list[i], Der::from_slice(DER_LIST[i])));
13 i += 1;
14 }
15
16 list
17};
18
19pub static RUSTLS_CERTIFICATE_DER_LIST: [CertificateDer<'static>; DER_LIST_LEN] = {
20 let mut list = [const { CertificateDer::from_slice(b"") }; DER_LIST_LEN];
21
22 let mut i = 0;
23 while i < DER_LIST_LEN {
24 mem::forget(mem::replace(&mut list[i], CertificateDer::from_slice(DER_LIST[i])));
25 i += 1;
26 }
27
28 list
29};
30
31#[cfg(feature="rustls-trust-anchor")]
32use rustls_pki_types::TrustAnchor;
33
34#[cfg(feature="rustls-trust-anchor")]
35pub fn rustls_trust_anchor_list() -> &'static [TrustAnchor<'static>; DER_LIST_LEN] {
36 #[cfg(not(feature="std"))]
37 {
38 use lazy_static::lazy_static;
39
40 lazy_static! {
41 static ref LIST: [TrustAnchor<'static>; DER_LIST_LEN] = gen_anchor_list();
42 }
43
44 &*LIST
45 }
46
47 #[cfg(feature="std")]
48 {
49 use once_cell::sync::Lazy;
50
51 static LIST: Lazy<[TrustAnchor<'static>; DER_LIST_LEN]> = Lazy::new(gen_anchor_list);
52
53 &*LIST
54 }
55}
56
57#[cfg(feature="rustls-trust-anchor")]
58fn gen_anchor_list() -> [TrustAnchor<'static>; DER_LIST_LEN] {
59 core::array::from_fn(|i| {
60 webpki::anchor_from_trusted_cert(&RUSTLS_CERTIFICATE_DER_LIST[i]).unwrap()
61 })
62}
63