mirror of
https://github.com/usestrix/firewall.git
synced 2026-11-09 13:31:32 -10:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9204017cf1 |
No files matched your search
@@ -1,4 +1,5 @@
|
||||
use rama::error::BoxError;
|
||||
use rama::tls::boring::core::sha::sha256;
|
||||
use rama::tls::boring::core::x509::X509;
|
||||
use rcgen::{
|
||||
BasicConstraints, CertificateParams, CertificateRevocationListParams, DistinguishedName,
|
||||
@@ -39,6 +40,12 @@ impl CertificateAuthority {
|
||||
(held == signer.subject_public_key_info()).then_some(ca)
|
||||
}
|
||||
|
||||
/// Unique to this CA, so a verifier's cached CRL from an earlier one never applies to it.
|
||||
pub fn crl_path(&self) -> String {
|
||||
let digest = sha256(self.pem.as_bytes());
|
||||
format!("/{}.crl", digest[..8].iter().map(|b| format!("{b:02x}")).collect::<String>())
|
||||
}
|
||||
|
||||
fn new(pem: String) -> Result<Self, BoxError> {
|
||||
Ok(Self { crt: X509::from_pem(pem.as_bytes())?, pem })
|
||||
}
|
||||
|
||||
@@ -50,3 +50,12 @@ fn ca_signs_an_empty_crl() {
|
||||
let crl = mitm::crl(&["registry.npmjs.org", "pypi.org"], &signer()).expect("sign a crl");
|
||||
assert_eq!(crl[0], 0x30, "a DER SEQUENCE");
|
||||
}
|
||||
|
||||
/// A re-minted CA must not inherit the old one's CRL from a verifier's cache.
|
||||
#[test]
|
||||
fn each_ca_names_its_own_crl() {
|
||||
let signer = signer();
|
||||
let npm = mitm::CertificateAuthority::generate(&["registry.npmjs.org"], &signer).expect("mint a ca");
|
||||
let pypi = mitm::CertificateAuthority::generate(&["pypi.org"], &signer).expect("mint a ca");
|
||||
assert_ne!(npm.crl_path(), pypi.crl_path());
|
||||
}
|
||||
Reference in new issue
Block a user