#![cfg(feature = "ring")]
use webpki::{KeyUsage, RevocationCheckDepth, RevocationOptions, RevocationOptionsBuilder};
fn check_cert(
ee: &[u8],
intermediates: &[&[u8]],
ca: &[u8],
revocation: Option<RevocationOptions>,
) -> Result<(), webpki::Error> {
let anchors = &[webpki::TrustAnchor::try_from_cert_der(ca).unwrap()];
let cert = webpki::EndEntityCert::try_from(ee).unwrap();
let time = webpki::Time::from_seconds_since_unix_epoch(0x1fed_f00d);
cert.verify_for_usage(
&[webpki::ECDSA_P256_SHA256],
anchors,
intermediates,
time,
KeyUsage::client_auth(),
revocation,
)
}
#[test]
fn no_crls_test() {
let ee = include_bytes!("client_auth_revocation/no_ku_chain.ee.der");
let intermediates = &[
include_bytes!("client_auth_revocation/no_ku_chain.int.a.ca.der").as_slice(),
include_bytes!("client_auth_revocation/no_ku_chain.int.b.ca.der").as_slice(),
];
let ca = include_bytes!("client_auth_revocation/no_ku_chain.root.ca.der");
let revocation = None;
assert_eq!(check_cert(ee, intermediates, ca, revocation), Ok(()));
}
#[cfg(feature = "alloc")]
#[test]
fn no_crls_test_owned() {
let ee = include_bytes!("client_auth_revocation/no_ku_chain.ee.der");
let intermediates = &[
include_bytes!("client_auth_revocation/no_ku_chain.int.a.ca.der").as_slice(),
include_bytes!("client_auth_revocation/no_ku_chain.int.b.ca.der").as_slice(),
];
let ca = include_bytes!("client_auth_revocation/no_ku_chain.root.ca.der");
let revocation = None;
assert_eq!(check_cert(ee, intermediates, ca, revocation), Ok(()));
}
#[test]
fn no_relevant_crl_ee_depth_allow_unknown() {
let ee = include_bytes!("client_auth_revocation/no_ku_chain.ee.der");
let intermediates = &[
include_bytes!("client_auth_revocation/no_ku_chain.int.a.ca.der").as_slice(),
include_bytes!("client_auth_revocation/no_ku_chain.int.b.ca.der").as_slice(),
];
let ca = include_bytes!("client_auth_revocation/no_ku_chain.root.ca.der");
let crls = &[&webpki::BorrowedCertRevocationList::from_der(
include_bytes!("client_auth_revocation/no_relevant_crl_ee_depth_allow_unknown.crl.der")
.as_slice(),
)
.unwrap() as &dyn webpki::CertRevocationList];
let builder = RevocationOptionsBuilder::new(crls).unwrap();
let builder = builder.with_depth(RevocationCheckDepth::EndEntity);
let builder = builder.allow_unknown_status();
let revocation = Some(builder.build());
assert_eq!(check_cert(ee, intermediates, ca, revocation), Ok(()));
}
#[cfg(feature = "alloc")]
#[test]
fn no_relevant_crl_ee_depth_allow_unknown_owned() {
let ee = include_bytes!("client_auth_revocation/no_ku_chain.ee.der");
let intermediates = &[
include_bytes!("client_auth_revocation/no_ku_chain.int.a.ca.der").as_slice(),
include_bytes!("client_auth_revocation/no_ku_chain.int.b.ca.der").as_slice(),
];
let ca = include_bytes!("client_auth_revocation/no_ku_chain.root.ca.der");
let crls = &[&webpki::BorrowedCertRevocationList::from_der(
include_bytes!("client_auth_revocation/no_relevant_crl_ee_depth_allow_unknown.crl.der")
.as_slice(),
)
.unwrap()
.to_owned()
.unwrap() as &dyn webpki::CertRevocationList];
let builder = RevocationOptionsBuilder::new(crls).unwrap();
let builder = builder.with_depth(RevocationCheckDepth::EndEntity);
let builder = builder.allow_unknown_status();
let revocation = Some(builder.build());
assert_eq!(check_cert(ee, intermediates, ca, revocation), Ok(()));
}
#[test]
fn no_relevant_crl_ee_depth_forbid_unknown() {
let ee = include_bytes!("client_auth_revocation/no_ku_chain.ee.der");
let intermediates = &[
include_bytes!("client_auth_revocation/no_ku_chain.int.a.ca.der").as_slice(),
include_bytes!("client_auth_revocation/no_ku_chain.int.b.ca.der").as_slice(),
];
let ca = include_bytes!("client_auth_revocation/no_ku_chain.root.ca.der");
let crls = &[&webpki::BorrowedCertRevocationList::from_der(
include_bytes!("client_auth_revocation/no_relevant_crl_ee_depth_forbid_unknown.crl.der")
.as_slice(),
)
.unwrap() as &dyn webpki::CertRevocationList];
let builder = RevocationOptionsBuilder::new(crls).unwrap();
let builder = builder.with_depth(RevocationCheckDepth::EndEntity);
let revocation = Some(builder.build());
assert_eq!(
check_cert(ee, intermediates, ca, revocation),
Err(webpki::Error::UnknownRevocationStatus)
);
}
#[cfg(feature = "alloc")]
#[test]
fn no_relevant_crl_ee_depth_forbid_unknown_owned() {
let ee = include_bytes!("client_auth_revocation/no_ku_chain.ee.der");
let intermediates = &[
include_bytes!("client_auth_revocation/no_ku_chain.int.a.ca.der").as_slice(),
include_bytes!("client_auth_revocation/no_ku_chain.int.b.ca.der").as_slice(),
];
let ca = include_bytes!("client_auth_revocation/no_ku_chain.root.ca.der");
let crls = &[&webpki::BorrowedCertRevocationList::from_der(
include_bytes!("client_auth_revocation/no_relevant_crl_ee_depth_forbid_unknown.crl.der")
.as_slice(),
)
.unwrap()
.to_owned()
.unwrap() as &dyn webpki::CertRevocationList];
let builder = RevocationOptionsBuilder::new(crls).unwrap();
let builder = builder.with_depth(RevocationCheckDepth::EndEntity);
let revocation = Some(builder.build());
assert_eq!(
check_cert(ee, intermediates, ca, revocation),
Err(webpki::Error::UnknownRevocationStatus)
);
}
#[test]
fn ee_not_revoked_ee_depth() {
let ee = include_bytes!("client_auth_revocation/no_ku_chain.ee.der");
let intermediates = &[
include_bytes!("client_auth_revocation/no_ku_chain.int.a.ca.der").as_slice(),
include_bytes!("client_auth_revocation/no_ku_chain.int.b.ca.der").as_slice(),
];
let ca = include_bytes!("client_auth_revocation/no_ku_chain.root.ca.der");
let crls = &[&webpki::BorrowedCertRevocationList::from_der(
include_bytes!("client_auth_revocation/ee_not_revoked_ee_depth.crl.der").as_slice(),
)
.unwrap() as &dyn webpki::CertRevocationList];
let builder = RevocationOptionsBuilder::new(crls).unwrap();
let builder = builder.with_depth(RevocationCheckDepth::EndEntity);
let builder = builder.allow_unknown_status();
let revocation = Some(builder.build());
assert_eq!(check_cert(ee, intermediates, ca, revocation), Ok(()));
}
#[cfg(feature = "alloc")]
#[test]
fn ee_not_revoked_ee_depth_owned() {
let ee = include_bytes!("client_auth_revocation/no_ku_chain.ee.der");
let intermediates = &[
include_bytes!("client_auth_revocation/no_ku_chain.int.a.ca.der").as_slice(),
include_bytes!("client_auth_revocation/no_ku_chain.int.b.ca.der").as_slice(),
];
let ca = include_bytes!("client_auth_revocation/no_ku_chain.root.ca.der");
let crls = &[&webpki::BorrowedCertRevocationList::from_der(
include_bytes!("client_auth_revocation/ee_not_revoked_ee_depth.crl.der").as_slice(),
)
.unwrap()
.to_owned()
.unwrap() as &dyn webpki::CertRevocationList];
let builder = RevocationOptionsBuilder::new(crls).unwrap();
let builder = builder.with_depth(RevocationCheckDepth::EndEntity);
let builder = builder.allow_unknown_status();
let revocation = Some(builder.build());
assert_eq!(check_cert(ee, intermediates, ca, revocation), Ok(()));
}
#[test]
fn ee_not_revoked_chain_depth() {
let ee = include_bytes!("client_auth_revocation/no_ku_chain.ee.der");
let intermediates = &[
include_bytes!("client_auth_revocation/no_ku_chain.int.a.ca.der").as_slice(),
include_bytes!("client_auth_revocation/no_ku_chain.int.b.ca.der").as_slice(),
];
let ca = include_bytes!("client_auth_revocation/no_ku_chain.root.ca.der");
let crls = &[&webpki::BorrowedCertRevocationList::from_der(
include_bytes!("client_auth_revocation/ee_not_revoked_chain_depth.crl.der").as_slice(),
)
.unwrap() as &dyn webpki::CertRevocationList];
let builder = RevocationOptionsBuilder::new(crls).unwrap();
let builder = builder.allow_unknown_status();
let revocation = Some(builder.build());
assert_eq!(check_cert(ee, intermediates, ca, revocation), Ok(()));
}
#[cfg(feature = "alloc")]
#[test]
fn ee_not_revoked_chain_depth_owned() {
let ee = include_bytes!("client_auth_revocation/no_ku_chain.ee.der");
let intermediates = &[
include_bytes!("client_auth_revocation/no_ku_chain.int.a.ca.der").as_slice(),
include_bytes!("client_auth_revocation/no_ku_chain.int.b.ca.der").as_slice(),
];
let ca = include_bytes!("client_auth_revocation/no_ku_chain.root.ca.der");
let crls = &[&webpki::BorrowedCertRevocationList::from_der(
include_bytes!("client_auth_revocation/ee_not_revoked_chain_depth.crl.der").as_slice(),
)
.unwrap()
.to_owned()
.unwrap() as &dyn webpki::CertRevocationList];
let builder = RevocationOptionsBuilder::new(crls).unwrap();
let builder = builder.allow_unknown_status();
let revocation = Some(builder.build());
assert_eq!(check_cert(ee, intermediates, ca, revocation), Ok(()));
}
#[test]
fn ee_revoked_badsig_ee_depth() {
let ee = include_bytes!("client_auth_revocation/no_ku_chain.ee.der");
let intermediates = &[
include_bytes!("client_auth_revocation/no_ku_chain.int.a.ca.der").as_slice(),
include_bytes!("client_auth_revocation/no_ku_chain.int.b.ca.der").as_slice(),
];
let ca = include_bytes!("client_auth_revocation/no_ku_chain.root.ca.der");
let crls = &[&webpki::BorrowedCertRevocationList::from_der(
include_bytes!("client_auth_revocation/ee_revoked_badsig_ee_depth.crl.der").as_slice(),
)
.unwrap() as &dyn webpki::CertRevocationList];
let builder = RevocationOptionsBuilder::new(crls).unwrap();
let builder = builder.with_depth(RevocationCheckDepth::EndEntity);
let builder = builder.allow_unknown_status();
let revocation = Some(builder.build());
assert_eq!(
check_cert(ee, intermediates, ca, revocation),
Err(webpki::Error::InvalidCrlSignatureForPublicKey)
);
}
#[cfg(feature = "alloc")]
#[test]
fn ee_revoked_badsig_ee_depth_owned() {
let ee = include_bytes!("client_auth_revocation/no_ku_chain.ee.der");
let intermediates = &[
include_bytes!("client_auth_revocation/no_ku_chain.int.a.ca.der").as_slice(),
include_bytes!("client_auth_revocation/no_ku_chain.int.b.ca.der").as_slice(),
];
let ca = include_bytes!("client_auth_revocation/no_ku_chain.root.ca.der");
let crls = &[&webpki::BorrowedCertRevocationList::from_der(
include_bytes!("client_auth_revocation/ee_revoked_badsig_ee_depth.crl.der").as_slice(),
)
.unwrap()
.to_owned()
.unwrap() as &dyn webpki::CertRevocationList];
let builder = RevocationOptionsBuilder::new(crls).unwrap();
let builder = builder.with_depth(RevocationCheckDepth::EndEntity);
let builder = builder.allow_unknown_status();
let revocation = Some(builder.build());
assert_eq!(
check_cert(ee, intermediates, ca, revocation),
Err(webpki::Error::InvalidCrlSignatureForPublicKey)
);
}
#[test]
fn ee_revoked_wrong_ku_ee_depth() {
let ee = include_bytes!("client_auth_revocation/no_crl_ku_chain.ee.der");
let intermediates = &[
include_bytes!("client_auth_revocation/no_crl_ku_chain.int.a.ca.der").as_slice(),
include_bytes!("client_auth_revocation/no_crl_ku_chain.int.b.ca.der").as_slice(),
];
let ca = include_bytes!("client_auth_revocation/no_crl_ku_chain.root.ca.der");
let crls = &[&webpki::BorrowedCertRevocationList::from_der(
include_bytes!("client_auth_revocation/ee_revoked_wrong_ku_ee_depth.crl.der").as_slice(),
)
.unwrap() as &dyn webpki::CertRevocationList];
let builder = RevocationOptionsBuilder::new(crls).unwrap();
let builder = builder.with_depth(RevocationCheckDepth::EndEntity);
let builder = builder.allow_unknown_status();
let revocation = Some(builder.build());
assert_eq!(
check_cert(ee, intermediates, ca, revocation),
Err(webpki::Error::IssuerNotCrlSigner)
);
}
#[cfg(feature = "alloc")]
#[test]
fn ee_revoked_wrong_ku_ee_depth_owned() {
let ee = include_bytes!("client_auth_revocation/no_crl_ku_chain.ee.der");
let intermediates = &[
include_bytes!("client_auth_revocation/no_crl_ku_chain.int.a.ca.der").as_slice(),
include_bytes!("client_auth_revocation/no_crl_ku_chain.int.b.ca.der").as_slice(),
];
let ca = include_bytes!("client_auth_revocation/no_crl_ku_chain.root.ca.der");
let crls = &[&webpki::BorrowedCertRevocationList::from_der(
include_bytes!("client_auth_revocation/ee_revoked_wrong_ku_ee_depth.crl.der").as_slice(),
)
.unwrap()
.to_owned()
.unwrap() as &dyn webpki::CertRevocationList];
let builder = RevocationOptionsBuilder::new(crls).unwrap();
let builder = builder.with_depth(RevocationCheckDepth::EndEntity);
let builder = builder.allow_unknown_status();
let revocation = Some(builder.build());
assert_eq!(
check_cert(ee, intermediates, ca, revocation),
Err(webpki::Error::IssuerNotCrlSigner)
);
}
#[test]
fn ee_not_revoked_wrong_ku_ee_depth() {
let ee = include_bytes!("client_auth_revocation/no_crl_ku_chain.ee.der");
let intermediates = &[
include_bytes!("client_auth_revocation/no_crl_ku_chain.int.a.ca.der").as_slice(),
include_bytes!("client_auth_revocation/no_crl_ku_chain.int.b.ca.der").as_slice(),
];
let ca = include_bytes!("client_auth_revocation/no_crl_ku_chain.root.ca.der");
let crls = &[&webpki::BorrowedCertRevocationList::from_der(
include_bytes!("client_auth_revocation/ee_not_revoked_wrong_ku_ee_depth.crl.der")
.as_slice(),
)
.unwrap() as &dyn webpki::CertRevocationList];
let builder = RevocationOptionsBuilder::new(crls).unwrap();
let builder = builder.with_depth(RevocationCheckDepth::EndEntity);
let builder = builder.allow_unknown_status();
let revocation = Some(builder.build());
assert_eq!(
check_cert(ee, intermediates, ca, revocation),
Err(webpki::Error::IssuerNotCrlSigner)
);
}
#[cfg(feature = "alloc")]
#[test]
fn ee_not_revoked_wrong_ku_ee_depth_owned() {
let ee = include_bytes!("client_auth_revocation/no_crl_ku_chain.ee.der");
let intermediates = &[
include_bytes!("client_auth_revocation/no_crl_ku_chain.int.a.ca.der").as_slice(),
include_bytes!("client_auth_revocation/no_crl_ku_chain.int.b.ca.der").as_slice(),
];
let ca = include_bytes!("client_auth_revocation/no_crl_ku_chain.root.ca.der");
let crls = &[&webpki::BorrowedCertRevocationList::from_der(
include_bytes!("client_auth_revocation/ee_not_revoked_wrong_ku_ee_depth.crl.der")
.as_slice(),
)
.unwrap()
.to_owned()
.unwrap() as &dyn webpki::CertRevocationList];
let builder = RevocationOptionsBuilder::new(crls).unwrap();
let builder = builder.with_depth(RevocationCheckDepth::EndEntity);
let builder = builder.allow_unknown_status();
let revocation = Some(builder.build());
assert_eq!(
check_cert(ee, intermediates, ca, revocation),
Err(webpki::Error::IssuerNotCrlSigner)
);
}
#[test]
fn ee_revoked_no_ku_ee_depth() {
let ee = include_bytes!("client_auth_revocation/no_ku_chain.ee.der");
let intermediates = &[
include_bytes!("client_auth_revocation/no_ku_chain.int.a.ca.der").as_slice(),
include_bytes!("client_auth_revocation/no_ku_chain.int.b.ca.der").as_slice(),
];
let ca = include_bytes!("client_auth_revocation/no_ku_chain.root.ca.der");
let crls = &[&webpki::BorrowedCertRevocationList::from_der(
include_bytes!("client_auth_revocation/ee_revoked_no_ku_ee_depth.crl.der").as_slice(),
)
.unwrap() as &dyn webpki::CertRevocationList];
let builder = RevocationOptionsBuilder::new(crls).unwrap();
let builder = builder.with_depth(RevocationCheckDepth::EndEntity);
let builder = builder.allow_unknown_status();
let revocation = Some(builder.build());
assert_eq!(
check_cert(ee, intermediates, ca, revocation),
Err(webpki::Error::CertRevoked)
);
}
#[cfg(feature = "alloc")]
#[test]
fn ee_revoked_no_ku_ee_depth_owned() {
let ee = include_bytes!("client_auth_revocation/no_ku_chain.ee.der");
let intermediates = &[
include_bytes!("client_auth_revocation/no_ku_chain.int.a.ca.der").as_slice(),
include_bytes!("client_auth_revocation/no_ku_chain.int.b.ca.der").as_slice(),
];
let ca = include_bytes!("client_auth_revocation/no_ku_chain.root.ca.der");
let crls = &[&webpki::BorrowedCertRevocationList::from_der(
include_bytes!("client_auth_revocation/ee_revoked_no_ku_ee_depth.crl.der").as_slice(),
)
.unwrap()
.to_owned()
.unwrap() as &dyn webpki::CertRevocationList];
let builder = RevocationOptionsBuilder::new(crls).unwrap();
let builder = builder.with_depth(RevocationCheckDepth::EndEntity);
let builder = builder.allow_unknown_status();
let revocation = Some(builder.build());
assert_eq!(
check_cert(ee, intermediates, ca, revocation),
Err(webpki::Error::CertRevoked)
);
}
#[test]
fn ee_revoked_crl_ku_ee_depth() {
let ee = include_bytes!("client_auth_revocation/ku_chain.ee.der");
let intermediates = &[
include_bytes!("client_auth_revocation/ku_chain.int.a.ca.der").as_slice(),
include_bytes!("client_auth_revocation/ku_chain.int.b.ca.der").as_slice(),
];
let ca = include_bytes!("client_auth_revocation/ku_chain.root.ca.der");
let crls = &[&webpki::BorrowedCertRevocationList::from_der(
include_bytes!("client_auth_revocation/ee_revoked_crl_ku_ee_depth.crl.der").as_slice(),
)
.unwrap() as &dyn webpki::CertRevocationList];
let builder = RevocationOptionsBuilder::new(crls).unwrap();
let builder = builder.with_depth(RevocationCheckDepth::EndEntity);
let builder = builder.allow_unknown_status();
let revocation = Some(builder.build());
assert_eq!(
check_cert(ee, intermediates, ca, revocation),
Err(webpki::Error::CertRevoked)
);
}
#[cfg(feature = "alloc")]
#[test]
fn ee_revoked_crl_ku_ee_depth_owned() {
let ee = include_bytes!("client_auth_revocation/ku_chain.ee.der");
let intermediates = &[
include_bytes!("client_auth_revocation/ku_chain.int.a.ca.der").as_slice(),
include_bytes!("client_auth_revocation/ku_chain.int.b.ca.der").as_slice(),
];
let ca = include_bytes!("client_auth_revocation/ku_chain.root.ca.der");
let crls = &[&webpki::BorrowedCertRevocationList::from_der(
include_bytes!("client_auth_revocation/ee_revoked_crl_ku_ee_depth.crl.der").as_slice(),
)
.unwrap()
.to_owned()
.unwrap() as &dyn webpki::CertRevocationList];
let builder = RevocationOptionsBuilder::new(crls).unwrap();
let builder = builder.with_depth(RevocationCheckDepth::EndEntity);
let builder = builder.allow_unknown_status();
let revocation = Some(builder.build());
assert_eq!(
check_cert(ee, intermediates, ca, revocation),
Err(webpki::Error::CertRevoked)
);
}
#[test]
fn no_crls_test_chain_depth() {
let ee = include_bytes!("client_auth_revocation/no_ku_chain.ee.der");
let intermediates = &[
include_bytes!("client_auth_revocation/no_ku_chain.int.a.ca.der").as_slice(),
include_bytes!("client_auth_revocation/no_ku_chain.int.b.ca.der").as_slice(),
];
let ca = include_bytes!("client_auth_revocation/no_ku_chain.root.ca.der");
let revocation = None;
assert_eq!(check_cert(ee, intermediates, ca, revocation), Ok(()));
}
#[cfg(feature = "alloc")]
#[test]
fn no_crls_test_chain_depth_owned() {
let ee = include_bytes!("client_auth_revocation/no_ku_chain.ee.der");
let intermediates = &[
include_bytes!("client_auth_revocation/no_ku_chain.int.a.ca.der").as_slice(),
include_bytes!("client_auth_revocation/no_ku_chain.int.b.ca.der").as_slice(),
];
let ca = include_bytes!("client_auth_revocation/no_ku_chain.root.ca.der");
let revocation = None;
assert_eq!(check_cert(ee, intermediates, ca, revocation), Ok(()));
}
#[test]
fn no_relevant_crl_chain_depth_allow_unknown() {
let ee = include_bytes!("client_auth_revocation/no_ku_chain.ee.der");
let intermediates = &[
include_bytes!("client_auth_revocation/no_ku_chain.int.a.ca.der").as_slice(),
include_bytes!("client_auth_revocation/no_ku_chain.int.b.ca.der").as_slice(),
];
let ca = include_bytes!("client_auth_revocation/no_ku_chain.root.ca.der");
let crls = &[&webpki::BorrowedCertRevocationList::from_der(
include_bytes!("client_auth_revocation/no_relevant_crl_chain_depth_allow_unknown.crl.der")
.as_slice(),
)
.unwrap() as &dyn webpki::CertRevocationList];
let builder = RevocationOptionsBuilder::new(crls).unwrap();
let builder = builder.allow_unknown_status();
let revocation = Some(builder.build());
assert_eq!(check_cert(ee, intermediates, ca, revocation), Ok(()));
}
#[cfg(feature = "alloc")]
#[test]
fn no_relevant_crl_chain_depth_allow_unknown_owned() {
let ee = include_bytes!("client_auth_revocation/no_ku_chain.ee.der");
let intermediates = &[
include_bytes!("client_auth_revocation/no_ku_chain.int.a.ca.der").as_slice(),
include_bytes!("client_auth_revocation/no_ku_chain.int.b.ca.der").as_slice(),
];
let ca = include_bytes!("client_auth_revocation/no_ku_chain.root.ca.der");
let crls = &[&webpki::BorrowedCertRevocationList::from_der(
include_bytes!("client_auth_revocation/no_relevant_crl_chain_depth_allow_unknown.crl.der")
.as_slice(),
)
.unwrap()
.to_owned()
.unwrap() as &dyn webpki::CertRevocationList];
let builder = RevocationOptionsBuilder::new(crls).unwrap();
let builder = builder.allow_unknown_status();
let revocation = Some(builder.build());
assert_eq!(check_cert(ee, intermediates, ca, revocation), Ok(()));
}
#[test]
fn no_relevant_crl_chain_depth_forbid_unknown() {
let ee = include_bytes!("client_auth_revocation/no_ku_chain.ee.der");
let intermediates = &[
include_bytes!("client_auth_revocation/no_ku_chain.int.a.ca.der").as_slice(),
include_bytes!("client_auth_revocation/no_ku_chain.int.b.ca.der").as_slice(),
];
let ca = include_bytes!("client_auth_revocation/no_ku_chain.root.ca.der");
let crls = &[&webpki::BorrowedCertRevocationList::from_der(
include_bytes!("client_auth_revocation/no_relevant_crl_chain_depth_forbid_unknown.crl.der")
.as_slice(),
)
.unwrap() as &dyn webpki::CertRevocationList];
let builder = RevocationOptionsBuilder::new(crls).unwrap();
let revocation = Some(builder.build());
assert_eq!(
check_cert(ee, intermediates, ca, revocation),
Err(webpki::Error::UnknownRevocationStatus)
);
}
#[cfg(feature = "alloc")]
#[test]
fn no_relevant_crl_chain_depth_forbid_unknown_owned() {
let ee = include_bytes!("client_auth_revocation/no_ku_chain.ee.der");
let intermediates = &[
include_bytes!("client_auth_revocation/no_ku_chain.int.a.ca.der").as_slice(),
include_bytes!("client_auth_revocation/no_ku_chain.int.b.ca.der").as_slice(),
];
let ca = include_bytes!("client_auth_revocation/no_ku_chain.root.ca.der");
let crls = &[&webpki::BorrowedCertRevocationList::from_der(
include_bytes!("client_auth_revocation/no_relevant_crl_chain_depth_forbid_unknown.crl.der")
.as_slice(),
)
.unwrap()
.to_owned()
.unwrap() as &dyn webpki::CertRevocationList];
let builder = RevocationOptionsBuilder::new(crls).unwrap();
let revocation = Some(builder.build());
assert_eq!(
check_cert(ee, intermediates, ca, revocation),
Err(webpki::Error::UnknownRevocationStatus)
);
}
#[test]
fn int_not_revoked_chain_depth() {
let ee = include_bytes!("client_auth_revocation/no_ku_chain.ee.der");
let intermediates = &[
include_bytes!("client_auth_revocation/no_ku_chain.int.a.ca.der").as_slice(),
include_bytes!("client_auth_revocation/no_ku_chain.int.b.ca.der").as_slice(),
];
let ca = include_bytes!("client_auth_revocation/no_ku_chain.root.ca.der");
let crls = &[&webpki::BorrowedCertRevocationList::from_der(
include_bytes!("client_auth_revocation/int_not_revoked_chain_depth.crl.der").as_slice(),
)
.unwrap() as &dyn webpki::CertRevocationList];
let builder = RevocationOptionsBuilder::new(crls).unwrap();
let builder = builder.allow_unknown_status();
let revocation = Some(builder.build());
assert_eq!(check_cert(ee, intermediates, ca, revocation), Ok(()));
}
#[cfg(feature = "alloc")]
#[test]
fn int_not_revoked_chain_depth_owned() {
let ee = include_bytes!("client_auth_revocation/no_ku_chain.ee.der");
let intermediates = &[
include_bytes!("client_auth_revocation/no_ku_chain.int.a.ca.der").as_slice(),
include_bytes!("client_auth_revocation/no_ku_chain.int.b.ca.der").as_slice(),
];
let ca = include_bytes!("client_auth_revocation/no_ku_chain.root.ca.der");
let crls = &[&webpki::BorrowedCertRevocationList::from_der(
include_bytes!("client_auth_revocation/int_not_revoked_chain_depth.crl.der").as_slice(),
)
.unwrap()
.to_owned()
.unwrap() as &dyn webpki::CertRevocationList];
let builder = RevocationOptionsBuilder::new(crls).unwrap();
let builder = builder.allow_unknown_status();
let revocation = Some(builder.build());
assert_eq!(check_cert(ee, intermediates, ca, revocation), Ok(()));
}
#[test]
fn int_not_revoked_chain_depth_forbid_unknown() {
let ee = include_bytes!("client_auth_revocation/no_ku_chain.ee.der");
let intermediates = &[
include_bytes!("client_auth_revocation/no_ku_chain.int.a.ca.der").as_slice(),
include_bytes!("client_auth_revocation/no_ku_chain.int.b.ca.der").as_slice(),
];
let ca = include_bytes!("client_auth_revocation/no_ku_chain.root.ca.der");
let crls = &[
&webpki::BorrowedCertRevocationList::from_der(
include_bytes!(
"client_auth_revocation/int_not_revoked_chain_depth_forbid_unknown_ee.crl.der"
)
.as_slice(),
)
.unwrap() as &dyn webpki::CertRevocationList,
&webpki::BorrowedCertRevocationList::from_der(
include_bytes!(
"client_auth_revocation/int_not_revoked_chain_depth_forbid_unknown.crl.der"
)
.as_slice(),
)
.unwrap() as &dyn webpki::CertRevocationList,
&webpki::BorrowedCertRevocationList::from_der(
include_bytes!(
"client_auth_revocation/int_not_revoked_chain_depth_forbid_unknown_b.crl.der"
)
.as_slice(),
)
.unwrap() as &dyn webpki::CertRevocationList,
];
let builder = RevocationOptionsBuilder::new(crls).unwrap();
let revocation = Some(builder.build());
assert_eq!(check_cert(ee, intermediates, ca, revocation), Ok(()));
}
#[cfg(feature = "alloc")]
#[test]
fn int_not_revoked_chain_depth_forbid_unknown_owned() {
let ee = include_bytes!("client_auth_revocation/no_ku_chain.ee.der");
let intermediates = &[
include_bytes!("client_auth_revocation/no_ku_chain.int.a.ca.der").as_slice(),
include_bytes!("client_auth_revocation/no_ku_chain.int.b.ca.der").as_slice(),
];
let ca = include_bytes!("client_auth_revocation/no_ku_chain.root.ca.der");
let crls = &[
&webpki::BorrowedCertRevocationList::from_der(
include_bytes!(
"client_auth_revocation/int_not_revoked_chain_depth_forbid_unknown_ee.crl.der"
)
.as_slice(),
)
.unwrap()
.to_owned()
.unwrap() as &dyn webpki::CertRevocationList,
&webpki::BorrowedCertRevocationList::from_der(
include_bytes!(
"client_auth_revocation/int_not_revoked_chain_depth_forbid_unknown.crl.der"
)
.as_slice(),
)
.unwrap()
.to_owned()
.unwrap() as &dyn webpki::CertRevocationList,
&webpki::BorrowedCertRevocationList::from_der(
include_bytes!(
"client_auth_revocation/int_not_revoked_chain_depth_forbid_unknown_b.crl.der"
)
.as_slice(),
)
.unwrap()
.to_owned()
.unwrap() as &dyn webpki::CertRevocationList,
];
let builder = RevocationOptionsBuilder::new(crls).unwrap();
let revocation = Some(builder.build());
assert_eq!(check_cert(ee, intermediates, ca, revocation), Ok(()));
}
#[test]
fn int_revoked_badsig_chain_depth() {
let ee = include_bytes!("client_auth_revocation/no_ku_chain.ee.der");
let intermediates = &[
include_bytes!("client_auth_revocation/no_ku_chain.int.a.ca.der").as_slice(),
include_bytes!("client_auth_revocation/no_ku_chain.int.b.ca.der").as_slice(),
];
let ca = include_bytes!("client_auth_revocation/no_ku_chain.root.ca.der");
let crls = &[&webpki::BorrowedCertRevocationList::from_der(
include_bytes!("client_auth_revocation/int_revoked_badsig_chain_depth.crl.der").as_slice(),
)
.unwrap() as &dyn webpki::CertRevocationList];
let builder = RevocationOptionsBuilder::new(crls).unwrap();
let builder = builder.allow_unknown_status();
let revocation = Some(builder.build());
assert_eq!(
check_cert(ee, intermediates, ca, revocation),
Err(webpki::Error::InvalidCrlSignatureForPublicKey)
);
}
#[cfg(feature = "alloc")]
#[test]
fn int_revoked_badsig_chain_depth_owned() {
let ee = include_bytes!("client_auth_revocation/no_ku_chain.ee.der");
let intermediates = &[
include_bytes!("client_auth_revocation/no_ku_chain.int.a.ca.der").as_slice(),
include_bytes!("client_auth_revocation/no_ku_chain.int.b.ca.der").as_slice(),
];
let ca = include_bytes!("client_auth_revocation/no_ku_chain.root.ca.der");
let crls = &[&webpki::BorrowedCertRevocationList::from_der(
include_bytes!("client_auth_revocation/int_revoked_badsig_chain_depth.crl.der").as_slice(),
)
.unwrap()
.to_owned()
.unwrap() as &dyn webpki::CertRevocationList];
let builder = RevocationOptionsBuilder::new(crls).unwrap();
let builder = builder.allow_unknown_status();
let revocation = Some(builder.build());
assert_eq!(
check_cert(ee, intermediates, ca, revocation),
Err(webpki::Error::InvalidCrlSignatureForPublicKey)
);
}
#[test]
fn int_revoked_wrong_ku_chain_depth() {
let ee = include_bytes!("client_auth_revocation/no_crl_ku_chain.ee.der");
let intermediates = &[
include_bytes!("client_auth_revocation/no_crl_ku_chain.int.a.ca.der").as_slice(),
include_bytes!("client_auth_revocation/no_crl_ku_chain.int.b.ca.der").as_slice(),
];
let ca = include_bytes!("client_auth_revocation/no_crl_ku_chain.root.ca.der");
let crls = &[&webpki::BorrowedCertRevocationList::from_der(
include_bytes!("client_auth_revocation/int_revoked_wrong_ku_chain_depth.crl.der")
.as_slice(),
)
.unwrap() as &dyn webpki::CertRevocationList];
let builder = RevocationOptionsBuilder::new(crls).unwrap();
let builder = builder.allow_unknown_status();
let revocation = Some(builder.build());
assert_eq!(
check_cert(ee, intermediates, ca, revocation),
Err(webpki::Error::IssuerNotCrlSigner)
);
}
#[cfg(feature = "alloc")]
#[test]
fn int_revoked_wrong_ku_chain_depth_owned() {
let ee = include_bytes!("client_auth_revocation/no_crl_ku_chain.ee.der");
let intermediates = &[
include_bytes!("client_auth_revocation/no_crl_ku_chain.int.a.ca.der").as_slice(),
include_bytes!("client_auth_revocation/no_crl_ku_chain.int.b.ca.der").as_slice(),
];
let ca = include_bytes!("client_auth_revocation/no_crl_ku_chain.root.ca.der");
let crls = &[&webpki::BorrowedCertRevocationList::from_der(
include_bytes!("client_auth_revocation/int_revoked_wrong_ku_chain_depth.crl.der")
.as_slice(),
)
.unwrap()
.to_owned()
.unwrap() as &dyn webpki::CertRevocationList];
let builder = RevocationOptionsBuilder::new(crls).unwrap();
let builder = builder.allow_unknown_status();
let revocation = Some(builder.build());
assert_eq!(
check_cert(ee, intermediates, ca, revocation),
Err(webpki::Error::IssuerNotCrlSigner)
);
}
#[test]
fn ee_revoked_chain_depth() {
let ee = include_bytes!("client_auth_revocation/no_ku_chain.ee.der");
let intermediates = &[
include_bytes!("client_auth_revocation/no_ku_chain.int.a.ca.der").as_slice(),
include_bytes!("client_auth_revocation/no_ku_chain.int.b.ca.der").as_slice(),
];
let ca = include_bytes!("client_auth_revocation/no_ku_chain.root.ca.der");
let crls = &[&webpki::BorrowedCertRevocationList::from_der(
include_bytes!("client_auth_revocation/ee_revoked_chain_depth.crl.der").as_slice(),
)
.unwrap() as &dyn webpki::CertRevocationList];
let builder = RevocationOptionsBuilder::new(crls).unwrap();
let builder = builder.allow_unknown_status();
let revocation = Some(builder.build());
assert_eq!(
check_cert(ee, intermediates, ca, revocation),
Err(webpki::Error::CertRevoked)
);
}
#[cfg(feature = "alloc")]
#[test]
fn ee_revoked_chain_depth_owned() {
let ee = include_bytes!("client_auth_revocation/no_ku_chain.ee.der");
let intermediates = &[
include_bytes!("client_auth_revocation/no_ku_chain.int.a.ca.der").as_slice(),
include_bytes!("client_auth_revocation/no_ku_chain.int.b.ca.der").as_slice(),
];
let ca = include_bytes!("client_auth_revocation/no_ku_chain.root.ca.der");
let crls = &[&webpki::BorrowedCertRevocationList::from_der(
include_bytes!("client_auth_revocation/ee_revoked_chain_depth.crl.der").as_slice(),
)
.unwrap()
.to_owned()
.unwrap() as &dyn webpki::CertRevocationList];
let builder = RevocationOptionsBuilder::new(crls).unwrap();
let builder = builder.allow_unknown_status();
let revocation = Some(builder.build());
assert_eq!(
check_cert(ee, intermediates, ca, revocation),
Err(webpki::Error::CertRevoked)
);
}
#[test]
fn int_revoked_no_ku_chain_depth() {
let ee = include_bytes!("client_auth_revocation/no_ku_chain.ee.der");
let intermediates = &[
include_bytes!("client_auth_revocation/no_ku_chain.int.a.ca.der").as_slice(),
include_bytes!("client_auth_revocation/no_ku_chain.int.b.ca.der").as_slice(),
];
let ca = include_bytes!("client_auth_revocation/no_ku_chain.root.ca.der");
let crls = &[&webpki::BorrowedCertRevocationList::from_der(
include_bytes!("client_auth_revocation/int_revoked_no_ku_chain_depth.crl.der").as_slice(),
)
.unwrap() as &dyn webpki::CertRevocationList];
let builder = RevocationOptionsBuilder::new(crls).unwrap();
let builder = builder.allow_unknown_status();
let revocation = Some(builder.build());
assert_eq!(
check_cert(ee, intermediates, ca, revocation),
Err(webpki::Error::CertRevoked)
);
}
#[cfg(feature = "alloc")]
#[test]
fn int_revoked_no_ku_chain_depth_owned() {
let ee = include_bytes!("client_auth_revocation/no_ku_chain.ee.der");
let intermediates = &[
include_bytes!("client_auth_revocation/no_ku_chain.int.a.ca.der").as_slice(),
include_bytes!("client_auth_revocation/no_ku_chain.int.b.ca.der").as_slice(),
];
let ca = include_bytes!("client_auth_revocation/no_ku_chain.root.ca.der");
let crls = &[&webpki::BorrowedCertRevocationList::from_der(
include_bytes!("client_auth_revocation/int_revoked_no_ku_chain_depth.crl.der").as_slice(),
)
.unwrap()
.to_owned()
.unwrap() as &dyn webpki::CertRevocationList];
let builder = RevocationOptionsBuilder::new(crls).unwrap();
let builder = builder.allow_unknown_status();
let revocation = Some(builder.build());
assert_eq!(
check_cert(ee, intermediates, ca, revocation),
Err(webpki::Error::CertRevoked)
);
}
#[test]
fn int_revoked_crl_ku_chain_depth() {
let ee = include_bytes!("client_auth_revocation/ku_chain.ee.der");
let intermediates = &[
include_bytes!("client_auth_revocation/ku_chain.int.a.ca.der").as_slice(),
include_bytes!("client_auth_revocation/ku_chain.int.b.ca.der").as_slice(),
];
let ca = include_bytes!("client_auth_revocation/ku_chain.root.ca.der");
let crls = &[&webpki::BorrowedCertRevocationList::from_der(
include_bytes!("client_auth_revocation/int_revoked_crl_ku_chain_depth.crl.der").as_slice(),
)
.unwrap() as &dyn webpki::CertRevocationList];
let builder = RevocationOptionsBuilder::new(crls).unwrap();
let builder = builder.allow_unknown_status();
let revocation = Some(builder.build());
assert_eq!(
check_cert(ee, intermediates, ca, revocation),
Err(webpki::Error::CertRevoked)
);
}
#[cfg(feature = "alloc")]
#[test]
fn int_revoked_crl_ku_chain_depth_owned() {
let ee = include_bytes!("client_auth_revocation/ku_chain.ee.der");
let intermediates = &[
include_bytes!("client_auth_revocation/ku_chain.int.a.ca.der").as_slice(),
include_bytes!("client_auth_revocation/ku_chain.int.b.ca.der").as_slice(),
];
let ca = include_bytes!("client_auth_revocation/ku_chain.root.ca.der");
let crls = &[&webpki::BorrowedCertRevocationList::from_der(
include_bytes!("client_auth_revocation/int_revoked_crl_ku_chain_depth.crl.der").as_slice(),
)
.unwrap()
.to_owned()
.unwrap() as &dyn webpki::CertRevocationList];
let builder = RevocationOptionsBuilder::new(crls).unwrap();
let builder = builder.allow_unknown_status();
let revocation = Some(builder.build());
assert_eq!(
check_cert(ee, intermediates, ca, revocation),
Err(webpki::Error::CertRevoked)
);
}
#[test]
fn ee_with_top_bit_set_serial_revoked() {
let ee = include_bytes!("client_auth_revocation/ku_chain.topbit.ee.der");
let intermediates = &[
include_bytes!("client_auth_revocation/ku_chain.int.a.ca.der").as_slice(),
include_bytes!("client_auth_revocation/ku_chain.int.b.ca.der").as_slice(),
];
let ca = include_bytes!("client_auth_revocation/ku_chain.root.ca.der");
let crls = &[&webpki::BorrowedCertRevocationList::from_der(
include_bytes!("client_auth_revocation/ee_with_top_bit_set_serial_revoked.crl.der")
.as_slice(),
)
.unwrap() as &dyn webpki::CertRevocationList];
let builder = RevocationOptionsBuilder::new(crls).unwrap();
let builder = builder.allow_unknown_status();
let revocation = Some(builder.build());
assert_eq!(
check_cert(ee, intermediates, ca, revocation),
Err(webpki::Error::CertRevoked)
);
}
#[cfg(feature = "alloc")]
#[test]
fn ee_with_top_bit_set_serial_revoked_owned() {
let ee = include_bytes!("client_auth_revocation/ku_chain.topbit.ee.der");
let intermediates = &[
include_bytes!("client_auth_revocation/ku_chain.int.a.ca.der").as_slice(),
include_bytes!("client_auth_revocation/ku_chain.int.b.ca.der").as_slice(),
];
let ca = include_bytes!("client_auth_revocation/ku_chain.root.ca.der");
let crls = &[&webpki::BorrowedCertRevocationList::from_der(
include_bytes!("client_auth_revocation/ee_with_top_bit_set_serial_revoked.crl.der")
.as_slice(),
)
.unwrap()
.to_owned()
.unwrap() as &dyn webpki::CertRevocationList];
let builder = RevocationOptionsBuilder::new(crls).unwrap();
let builder = builder.allow_unknown_status();
let revocation = Some(builder.build());
assert_eq!(
check_cert(ee, intermediates, ca, revocation),
Err(webpki::Error::CertRevoked)
);
}
#[test]
fn ee_no_dp_crl_idp() {
let ee = include_bytes!("client_auth_revocation/no_ku_chain.ee.der");
let intermediates = &[
include_bytes!("client_auth_revocation/no_ku_chain.int.a.ca.der").as_slice(),
include_bytes!("client_auth_revocation/no_ku_chain.int.b.ca.der").as_slice(),
];
let ca = include_bytes!("client_auth_revocation/no_ku_chain.root.ca.der");
let crls = &[&webpki::BorrowedCertRevocationList::from_der(
include_bytes!("client_auth_revocation/ee_no_dp_crl_idp.crl.der").as_slice(),
)
.unwrap() as &dyn webpki::CertRevocationList];
let builder = RevocationOptionsBuilder::new(crls).unwrap();
let builder = builder.with_depth(RevocationCheckDepth::EndEntity);
let revocation = Some(builder.build());
assert_eq!(check_cert(ee, intermediates, ca, revocation), Ok(()));
}
#[cfg(feature = "alloc")]
#[test]
fn ee_no_dp_crl_idp_owned() {
let ee = include_bytes!("client_auth_revocation/no_ku_chain.ee.der");
let intermediates = &[
include_bytes!("client_auth_revocation/no_ku_chain.int.a.ca.der").as_slice(),
include_bytes!("client_auth_revocation/no_ku_chain.int.b.ca.der").as_slice(),
];
let ca = include_bytes!("client_auth_revocation/no_ku_chain.root.ca.der");
let crls = &[&webpki::BorrowedCertRevocationList::from_der(
include_bytes!("client_auth_revocation/ee_no_dp_crl_idp.crl.der").as_slice(),
)
.unwrap()
.to_owned()
.unwrap() as &dyn webpki::CertRevocationList];
let builder = RevocationOptionsBuilder::new(crls).unwrap();
let builder = builder.with_depth(RevocationCheckDepth::EndEntity);
let revocation = Some(builder.build());
assert_eq!(check_cert(ee, intermediates, ca, revocation), Ok(()));
}
#[test]
fn ee_crl_no_idp_unknown_status() {
let ee = include_bytes!("client_auth_revocation/dp_chain.ee.der");
let intermediates = &[
include_bytes!("client_auth_revocation/dp_chain.int.a.ca.der").as_slice(),
include_bytes!("client_auth_revocation/dp_chain.int.b.ca.der").as_slice(),
];
let ca = include_bytes!("client_auth_revocation/dp_chain.root.ca.der");
let crls = &[&webpki::BorrowedCertRevocationList::from_der(
include_bytes!("client_auth_revocation/ee_crl_no_idp_unknown_status.crl.der").as_slice(),
)
.unwrap() as &dyn webpki::CertRevocationList];
let builder = RevocationOptionsBuilder::new(crls).unwrap();
let builder = builder.with_depth(RevocationCheckDepth::EndEntity);
let revocation = Some(builder.build());
assert_eq!(
check_cert(ee, intermediates, ca, revocation),
Err(webpki::Error::UnknownRevocationStatus)
);
}
#[cfg(feature = "alloc")]
#[test]
fn ee_crl_no_idp_unknown_status_owned() {
let ee = include_bytes!("client_auth_revocation/dp_chain.ee.der");
let intermediates = &[
include_bytes!("client_auth_revocation/dp_chain.int.a.ca.der").as_slice(),
include_bytes!("client_auth_revocation/dp_chain.int.b.ca.der").as_slice(),
];
let ca = include_bytes!("client_auth_revocation/dp_chain.root.ca.der");
let crls = &[&webpki::BorrowedCertRevocationList::from_der(
include_bytes!("client_auth_revocation/ee_crl_no_idp_unknown_status.crl.der").as_slice(),
)
.unwrap()
.to_owned()
.unwrap() as &dyn webpki::CertRevocationList];
let builder = RevocationOptionsBuilder::new(crls).unwrap();
let builder = builder.with_depth(RevocationCheckDepth::EndEntity);
let revocation = Some(builder.build());
assert_eq!(
check_cert(ee, intermediates, ca, revocation),
Err(webpki::Error::UnknownRevocationStatus)
);
}
#[test]
fn ee_crl_mismatched_idp_unknown_status() {
let ee = include_bytes!("client_auth_revocation/dp_chain.ee.der");
let intermediates = &[
include_bytes!("client_auth_revocation/dp_chain.int.a.ca.der").as_slice(),
include_bytes!("client_auth_revocation/dp_chain.int.b.ca.der").as_slice(),
];
let ca = include_bytes!("client_auth_revocation/dp_chain.root.ca.der");
let crls = &[&webpki::BorrowedCertRevocationList::from_der(
include_bytes!("client_auth_revocation/ee_crl_mismatched_idp_unknown_status.crl.der")
.as_slice(),
)
.unwrap() as &dyn webpki::CertRevocationList];
let builder = RevocationOptionsBuilder::new(crls).unwrap();
let builder = builder.with_depth(RevocationCheckDepth::EndEntity);
let revocation = Some(builder.build());
assert_eq!(
check_cert(ee, intermediates, ca, revocation),
Err(webpki::Error::UnknownRevocationStatus)
);
}
#[cfg(feature = "alloc")]
#[test]
fn ee_crl_mismatched_idp_unknown_status_owned() {
let ee = include_bytes!("client_auth_revocation/dp_chain.ee.der");
let intermediates = &[
include_bytes!("client_auth_revocation/dp_chain.int.a.ca.der").as_slice(),
include_bytes!("client_auth_revocation/dp_chain.int.b.ca.der").as_slice(),
];
let ca = include_bytes!("client_auth_revocation/dp_chain.root.ca.der");
let crls = &[&webpki::BorrowedCertRevocationList::from_der(
include_bytes!("client_auth_revocation/ee_crl_mismatched_idp_unknown_status.crl.der")
.as_slice(),
)
.unwrap()
.to_owned()
.unwrap() as &dyn webpki::CertRevocationList];
let builder = RevocationOptionsBuilder::new(crls).unwrap();
let builder = builder.with_depth(RevocationCheckDepth::EndEntity);
let revocation = Some(builder.build());
assert_eq!(
check_cert(ee, intermediates, ca, revocation),
Err(webpki::Error::UnknownRevocationStatus)
);
}
#[test]
fn ee_indirect_dp_unknown_status() {
let ee = include_bytes!("client_auth_revocation/indirect_dp_chain.ee.der");
let intermediates = &[
include_bytes!("client_auth_revocation/indirect_dp_chain.int.a.ca.der").as_slice(),
include_bytes!("client_auth_revocation/indirect_dp_chain.int.b.ca.der").as_slice(),
];
let ca = include_bytes!("client_auth_revocation/indirect_dp_chain.root.ca.der");
let crls = &[&webpki::BorrowedCertRevocationList::from_der(
include_bytes!("client_auth_revocation/ee_indirect_dp_unknown_status.crl.der").as_slice(),
)
.unwrap() as &dyn webpki::CertRevocationList];
let builder = RevocationOptionsBuilder::new(crls).unwrap();
let builder = builder.with_depth(RevocationCheckDepth::EndEntity);
let revocation = Some(builder.build());
assert_eq!(
check_cert(ee, intermediates, ca, revocation),
Err(webpki::Error::UnknownRevocationStatus)
);
}
#[cfg(feature = "alloc")]
#[test]
fn ee_indirect_dp_unknown_status_owned() {
let ee = include_bytes!("client_auth_revocation/indirect_dp_chain.ee.der");
let intermediates = &[
include_bytes!("client_auth_revocation/indirect_dp_chain.int.a.ca.der").as_slice(),
include_bytes!("client_auth_revocation/indirect_dp_chain.int.b.ca.der").as_slice(),
];
let ca = include_bytes!("client_auth_revocation/indirect_dp_chain.root.ca.der");
let crls = &[&webpki::BorrowedCertRevocationList::from_der(
include_bytes!("client_auth_revocation/ee_indirect_dp_unknown_status.crl.der").as_slice(),
)
.unwrap()
.to_owned()
.unwrap() as &dyn webpki::CertRevocationList];
let builder = RevocationOptionsBuilder::new(crls).unwrap();
let builder = builder.with_depth(RevocationCheckDepth::EndEntity);
let revocation = Some(builder.build());
assert_eq!(
check_cert(ee, intermediates, ca, revocation),
Err(webpki::Error::UnknownRevocationStatus)
);
}
#[test]
fn ee_reasons_dp_unknown_status() {
let ee = include_bytes!("client_auth_revocation/reasons_dp_chain.ee.der");
let intermediates = &[
include_bytes!("client_auth_revocation/reasons_dp_chain.int.a.ca.der").as_slice(),
include_bytes!("client_auth_revocation/reasons_dp_chain.int.b.ca.der").as_slice(),
];
let ca = include_bytes!("client_auth_revocation/reasons_dp_chain.root.ca.der");
let crls = &[&webpki::BorrowedCertRevocationList::from_der(
include_bytes!("client_auth_revocation/ee_reasons_dp_unknown_status.crl.der").as_slice(),
)
.unwrap() as &dyn webpki::CertRevocationList];
let builder = RevocationOptionsBuilder::new(crls).unwrap();
let builder = builder.with_depth(RevocationCheckDepth::EndEntity);
let revocation = Some(builder.build());
assert_eq!(
check_cert(ee, intermediates, ca, revocation),
Err(webpki::Error::UnknownRevocationStatus)
);
}
#[cfg(feature = "alloc")]
#[test]
fn ee_reasons_dp_unknown_status_owned() {
let ee = include_bytes!("client_auth_revocation/reasons_dp_chain.ee.der");
let intermediates = &[
include_bytes!("client_auth_revocation/reasons_dp_chain.int.a.ca.der").as_slice(),
include_bytes!("client_auth_revocation/reasons_dp_chain.int.b.ca.der").as_slice(),
];
let ca = include_bytes!("client_auth_revocation/reasons_dp_chain.root.ca.der");
let crls = &[&webpki::BorrowedCertRevocationList::from_der(
include_bytes!("client_auth_revocation/ee_reasons_dp_unknown_status.crl.der").as_slice(),
)
.unwrap()
.to_owned()
.unwrap() as &dyn webpki::CertRevocationList];
let builder = RevocationOptionsBuilder::new(crls).unwrap();
let builder = builder.with_depth(RevocationCheckDepth::EndEntity);
let revocation = Some(builder.build());
assert_eq!(
check_cert(ee, intermediates, ca, revocation),
Err(webpki::Error::UnknownRevocationStatus)
);
}
#[test]
fn ee_nofullname_dp_unknown_status() {
let ee = include_bytes!("client_auth_revocation/nofullname_dp_chain.ee.der");
let intermediates = &[
include_bytes!("client_auth_revocation/nofullname_dp_chain.int.a.ca.der").as_slice(),
include_bytes!("client_auth_revocation/nofullname_dp_chain.int.b.ca.der").as_slice(),
];
let ca = include_bytes!("client_auth_revocation/nofullname_dp_chain.root.ca.der");
let crls = &[&webpki::BorrowedCertRevocationList::from_der(
include_bytes!("client_auth_revocation/ee_nofullname_dp_unknown_status.crl.der").as_slice(),
)
.unwrap() as &dyn webpki::CertRevocationList];
let builder = RevocationOptionsBuilder::new(crls).unwrap();
let builder = builder.with_depth(RevocationCheckDepth::EndEntity);
let revocation = Some(builder.build());
assert_eq!(
check_cert(ee, intermediates, ca, revocation),
Err(webpki::Error::UnknownRevocationStatus)
);
}
#[cfg(feature = "alloc")]
#[test]
fn ee_nofullname_dp_unknown_status_owned() {
let ee = include_bytes!("client_auth_revocation/nofullname_dp_chain.ee.der");
let intermediates = &[
include_bytes!("client_auth_revocation/nofullname_dp_chain.int.a.ca.der").as_slice(),
include_bytes!("client_auth_revocation/nofullname_dp_chain.int.b.ca.der").as_slice(),
];
let ca = include_bytes!("client_auth_revocation/nofullname_dp_chain.root.ca.der");
let crls = &[&webpki::BorrowedCertRevocationList::from_der(
include_bytes!("client_auth_revocation/ee_nofullname_dp_unknown_status.crl.der").as_slice(),
)
.unwrap()
.to_owned()
.unwrap() as &dyn webpki::CertRevocationList];
let builder = RevocationOptionsBuilder::new(crls).unwrap();
let builder = builder.with_depth(RevocationCheckDepth::EndEntity);
let revocation = Some(builder.build());
assert_eq!(
check_cert(ee, intermediates, ca, revocation),
Err(webpki::Error::UnknownRevocationStatus)
);
}
#[test]
fn ee_dp_idp_match() {
let ee = include_bytes!("client_auth_revocation/dp_chain.ee.der");
let intermediates = &[
include_bytes!("client_auth_revocation/dp_chain.int.a.ca.der").as_slice(),
include_bytes!("client_auth_revocation/dp_chain.int.b.ca.der").as_slice(),
];
let ca = include_bytes!("client_auth_revocation/dp_chain.root.ca.der");
let crls = &[&webpki::BorrowedCertRevocationList::from_der(
include_bytes!("client_auth_revocation/ee_dp_idp_match.crl.der").as_slice(),
)
.unwrap() as &dyn webpki::CertRevocationList];
let builder = RevocationOptionsBuilder::new(crls).unwrap();
let builder = builder.with_depth(RevocationCheckDepth::EndEntity);
let revocation = Some(builder.build());
assert_eq!(check_cert(ee, intermediates, ca, revocation), Ok(()));
}
#[cfg(feature = "alloc")]
#[test]
fn ee_dp_idp_match_owned() {
let ee = include_bytes!("client_auth_revocation/dp_chain.ee.der");
let intermediates = &[
include_bytes!("client_auth_revocation/dp_chain.int.a.ca.der").as_slice(),
include_bytes!("client_auth_revocation/dp_chain.int.b.ca.der").as_slice(),
];
let ca = include_bytes!("client_auth_revocation/dp_chain.root.ca.der");
let crls = &[&webpki::BorrowedCertRevocationList::from_der(
include_bytes!("client_auth_revocation/ee_dp_idp_match.crl.der").as_slice(),
)
.unwrap()
.to_owned()
.unwrap() as &dyn webpki::CertRevocationList];
let builder = RevocationOptionsBuilder::new(crls).unwrap();
let builder = builder.with_depth(RevocationCheckDepth::EndEntity);
let revocation = Some(builder.build());
assert_eq!(check_cert(ee, intermediates, ca, revocation), Ok(()));
}
#[test]
fn ee_dp_invalid() {
let ee = include_bytes!("client_auth_revocation/invalid_dp_chain.ee.der");
let intermediates = &[
include_bytes!("client_auth_revocation/invalid_dp_chain.int.a.ca.der").as_slice(),
include_bytes!("client_auth_revocation/invalid_dp_chain.int.b.ca.der").as_slice(),
];
let ca = include_bytes!("client_auth_revocation/invalid_dp_chain.root.ca.der");
let crls = &[&webpki::BorrowedCertRevocationList::from_der(
include_bytes!("client_auth_revocation/ee_dp_invalid.crl.der").as_slice(),
)
.unwrap() as &dyn webpki::CertRevocationList];
let builder = RevocationOptionsBuilder::new(crls).unwrap();
let builder = builder.with_depth(RevocationCheckDepth::EndEntity);
let revocation = Some(builder.build());
assert_eq!(
check_cert(ee, intermediates, ca, revocation),
Err(webpki::Error::UnknownRevocationStatus)
);
}
#[cfg(feature = "alloc")]
#[test]
fn ee_dp_invalid_owned() {
let ee = include_bytes!("client_auth_revocation/invalid_dp_chain.ee.der");
let intermediates = &[
include_bytes!("client_auth_revocation/invalid_dp_chain.int.a.ca.der").as_slice(),
include_bytes!("client_auth_revocation/invalid_dp_chain.int.b.ca.der").as_slice(),
];
let ca = include_bytes!("client_auth_revocation/invalid_dp_chain.root.ca.der");
let crls = &[&webpki::BorrowedCertRevocationList::from_der(
include_bytes!("client_auth_revocation/ee_dp_invalid.crl.der").as_slice(),
)
.unwrap()
.to_owned()
.unwrap() as &dyn webpki::CertRevocationList];
let builder = RevocationOptionsBuilder::new(crls).unwrap();
let builder = builder.with_depth(RevocationCheckDepth::EndEntity);
let revocation = Some(builder.build());
assert_eq!(
check_cert(ee, intermediates, ca, revocation),
Err(webpki::Error::UnknownRevocationStatus)
);
}