pkix-path 0.4.5

RFC 5280 X.509 certificate path validation — pure Rust, no_std
Documentation

pkix-path

RFC 5280 X.509 certification path validation — pure Rust, no_std.

The core validation engine. Implements the RFC 5280 §6.1 path validation algorithm with a pluggable cryptography interface so you can swap in any signature backend without changing validation logic.

When to use this crate directly

Use pkix-path directly when you need:

  • no_std (firmware, embedded, Caliptra/DPE)
  • A custom signature backend (FIPS, hardware HSM, wolfCrypt)
  • Fine-grained control over validation without revocation

For most applications, use [pkix-chain] instead, which wraps this crate together with revocation checking in a single ergonomic API.

Usage

use pkix_path::{validate_path, DefaultVerifier, TrustAnchor, ValidationPolicy};
use der::Decode as _;
use x509_cert::Certificate;

let chain = vec![
    Certificate::from_der(leaf_der)?,
    Certificate::from_der(intermediate_der)?,
];

let root_cert = Certificate::from_der(root_der)?;
let anchors = vec![TrustAnchor::from_cert(root_cert)];

let policy = ValidationPolicy::new(1_780_272_000);

let validated = validate_path(&chain, &anchors, &policy, &DefaultVerifier)?;
println!("anchor index: {}", validated.anchor_index);

Pluggable crypto

The [SignatureVerifier] trait is the seam between path validation logic and cryptographic operations:

use pkix_path::SignatureVerifier;
use spki::{AlgorithmIdentifierRef, SubjectPublicKeyInfoRef};

struct MyFipsVerifier;

impl SignatureVerifier for MyFipsVerifier {
    fn verify_signature(
        &self,
        algorithm: AlgorithmIdentifierRef<'_>,
        issuer_spki: SubjectPublicKeyInfoRef<'_>,
        message: &[u8],
        signature: &[u8],
    ) -> Result<(), pkix_path::VerificationError> {
        // dispatch to your FIPS-validated backend
        todo!()
    }
}

The [DefaultVerifier] provides RSA-PKCS1v15-SHA-256 and ECDSA-P-256-SHA-256 via RustCrypto. Enable the rsa and p256 features (both on by default).

no_std

pkix-path is no_std by default. The std feature enables std::error::Error impls on error types. Algorithm backends (rsa, p256) are no_std-compatible via default-features = false.

What is validated

Per RFC 5280 §6.1, for each certificate in the chain:

  • Signatures — each cert's signature is verified against the issuer's SPKI
  • Validity period — notBefore ≤ now ≤ notAfter
  • Name linkage — cert.issuer == issuer.subject for each adjacent pair
  • Trust anchor — final issuer matches a provided trust anchor
  • BasicConstraints — intermediates must have cA = TRUE
  • pathLenConstraint — enforced if present on intermediate CA certs
  • KeyUsage — keyCertSign bit enforced on CAs (configurable via policy)
  • Critical extensions — any unrecognised critical extension causes failure
  • Certificate policies — §6.1 policy state machine including anyPolicy, requireExplicitPolicy, and policy inhibit counters
  • Policy mappings — §6.1.3–6.1.5 mapping and constraint enforcement
  • Name constraints — §4.2.1.10 subtree checking for DNS names, RFC 822 addresses (including subject emailAddress and RFC 8398 SmtpUTF8Mailbox SANs), URIs, distinguished names, and IP addresses (IPv4/IPv6). Name forms whose constraints are not processed (otherName, ediPartyName, registeredID) are rejected whenever a constraint of that form is in effect, as §4.2.1.10 requires
  • Duplicate detection — issuer+serial uniqueness across the chain

Supported date range

UTCTime is supported for 1970-2049, where RFC 5280 §4.1.2.5.1 allows 1950-2049. A certificate dated in the missing twenty years is refused at the DER layer, before validation. Deliberate: the floor is the Unix epoch because der 0.8 puts it there, no conforming CA issues pre-1970 certificates, and lifting it would mean forking a dependency every consumer of this crate builds against. Fail-closed — such a certificate is refused, never misread — and OpenSSL does read them, so this is a real disagreement rather than a difference of strictness.

Not validated

  • Path building — chain must be caller-ordered, leaf first; use [pkix-path-builder] for unordered bags of certificates
  • CRL/OCSP revocation — use [pkix-revocation]
  • RFC 4518 full Unicode NFKC DN normalization (BMPString/TeletexString transcoding tracked as PKIX-l63j)

Standards

  • [RFC 5280] §4.2 — Certificate Extensions
  • [RFC 5280] §6 — Path Validation Algorithm
  • [RFC 5280] §4.2.1.10 — Name Constraints
  • [RFC 5280] §4.2.1.9, §6.1.5 — Certificate Policies and Policy Constraints
  • [FIPS 186-5] — Digital Signature Standard (ECDSA)

License

Apache-2.0 OR MIT