we (web engine): Experimental web browser project to understand the limits of Claude

X.509 certificate parsing and chain validation #55

open opened by pierrelf.com

Phase 5: Pure Rust Crypto#

Implement X.509 certificate parsing and certificate chain validation in the crypto crate.

Dependencies#

  • Requires ASN.1 DER parser
  • Requires SHA-2 (for certificate fingerprints and signature hash)
  • Requires RSA PKCS#1 v1.5 signature verification
  • Requires ECDSA signature verification

Requirements#

X.509 certificate parsing (RFC 5280):

  • Parse DER-encoded X.509v3 certificates
  • Extract: version, serial number, issuer, subject, validity (notBefore/notAfter), subject public key info, extensions
  • Parse common extensions: Basic Constraints, Key Usage, Subject Alternative Names (SAN), Authority Key Identifier, Subject Key Identifier
  • PEM decoding (Base64 between -----BEGIN CERTIFICATE----- markers)

Certificate chain validation:

  • Build chain from leaf to root
  • Verify each certificate's signature against its issuer's public key
  • Check validity period (not expired, not yet valid)
  • Check Basic Constraints (CA:TRUE for intermediate certs)
  • Verify subject/issuer chain linkage
  • Root CA trust store: embed Mozilla's root certificates or load from system

Signature algorithms to support:

  • sha256WithRSAEncryption
  • sha384WithRSAEncryption
  • ecdsa-with-SHA256
  • ecdsa-with-SHA384

Acceptance Criteria#

  • Parse real-world X.509 certificates (e.g., from Let's Encrypt, DigiCert)
  • Extract subject, issuer, SAN, validity period
  • PEM decoding
  • Verify certificate chain for a real HTTPS site
  • Reject expired certificates
  • Reject certificates with invalid signatures
  • Reject certificates where issuer doesn't match
  • Embedded root CA store (at minimum: Let's Encrypt, DigiCert, GlobalSign roots)
  • cargo test -p we-crypto passes
  • cargo clippy -p we-crypto -- -D warnings clean
sign up or login to add to the discussion
Labels

None yet.

assignee

None yet.

Participants 1
AT URI
at://did:plc:meotu43t6usg4qdwzenk4s2t/sh.tangled.repo.issue/3mgemv5xdty2c