Path validation
Validate TLS server and client certification paths with rustls-webpki.
import datetime as dt
from oxcrypto.pki.path import WEBPKI
path = WEBPKI.SERVER_AUTH.validate(
leaf,
trust_anchors=[root],
intermediates=[intermediate],
time=dt.datetime.now(dt.timezone.utc),
server_name="leaf.example",
)
assert path[0] == leaf and path[-1] == rootWEBPKI.SERVER_AUTH and WEBPKI.CLIENT_AUTH validate an end-entity
certificate for TLS server or client authentication with rustls-webpki. They
return the path from the leaf to the trust anchor as a list of Certificate
objects, or raise ValueError naming the rustls-webpki error, for example
UnknownIssuer, CertExpired, CertNotValidForName or CertRevoked.
trust_anchors are certificates whose subject, public key and name
constraints act as trust anchors; their own signature and dates are not
checked. time must be timezone-aware. server_name is a DNS name or IP
address checked against the Subject Alternative Name.
When crls is not empty, every certificate in the path except the trust
anchor needs a CRL from its issuer, and a certificate without one fails with
UnknownRevocationStatus. Expired CRLs are accepted. Without crls,
revocation is not checked.
rustls-webpki implements the Web PKI subset of RFC 5280: it checks
signatures, validity periods, Basic Constraints, name constraints, Key Usage
and Extended Key Usage. It does not process certificate policies, fetch CRLs
or check OCSP. Signatures are checked with the oxcrypto key classes listed in
the algorithm table.
Upstream
| Crate | Standard | Audit |
|---|---|---|
rustls-webpki 0.103.17, rustls-pki-types 1.16 | RFC 5280, RFC 6125 | No published audit of this release |
Tests use NIST PKITS 2011 tests 4.1.1 to 4.1.3, 4.2.2 and 4.4.3.