This crate provides types for representing X.509 certificates, keys and other types as commonly used in the rustls ecosystem. It is intended to be used by crates that need to work with such X.509 types, such as rustls, rustls-webpki, and others.
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Joe Birr-Pixton bb3c1da0e6
Some checks failed
rustls / Check semver compatibility (push) Has been cancelled
rustls / Validate external types appearing in public API (push) Has been cancelled
rustls / Build + test (push) Has been cancelled
rustls / Build + test-1 (push) Has been cancelled
rustls / Build + test-2 (push) Has been cancelled
rustls / Build + test-3 (push) Has been cancelled
rustls / Smoke-test fuzzing targets (push) Has been cancelled
rustls / Build + test-4 (push) Has been cancelled
rustls / Build wasm32 (push) Has been cancelled
rustls / msrv (macos-latest) (push) Has been cancelled
rustls / msrv (ubuntu-latest) (push) Has been cancelled
rustls / msrv (windows-latest) (push) Has been cancelled
rustls / Format (push) Has been cancelled
rustls / Clippy (push) Has been cancelled
rustls / Check side-channels on base64 decoder (push) Has been cancelled
rustls / audit (push) Has been cancelled
rustls / package (push) Has been cancelled
Adjust PEM size limit to account for huge CRLs
2026-04-24 12:53:19 +00:00
.github/workflows ci: sync cargo-check-external-types nightly 2025-12-12 15:40:16 +00:00
fuzz Add fuzz target for PEM decoding 2024-09-27 12:01:37 +00:00
src Adjust PEM size limit to account for huge CRLs 2026-04-24 12:53:19 +00:00
tests Adjust PEM size limit to account for huge CRLs 2026-04-24 12:53:19 +00:00
.gitignore Version Cargo.lock 2025-04-01 11:37:34 +00:00
Cargo.lock Bump version to 1.14.1 2026-04-24 11:34:33 +00:00
Cargo.toml Bump version to 1.14.1 2026-04-24 11:34:33 +00:00
deny.toml Add cargo deny check in CI 2025-04-01 11:37:34 +00:00
LICENSE-APACHE Start collection of basic data types (#1) 2023-08-31 09:08:06 +00:00
LICENSE-MIT Start collection of basic data types (#1) 2023-08-31 09:08:06 +00:00
README.md README: downplay rustls-pemfile 2024-09-27 12:01:37 +00:00
rustfmt.toml rustfmt: style_edition 2024 2025-02-21 14:46:00 +00:00

rustls-pki-types

Build Status Documentation Chat

This crate provides types for representing X.509 certificates, keys and other types as commonly used in the rustls ecosystem. It is intended to be used by crates that need to work with such X.509 types, such as rustls, rustls-webpki, and others.

Some of these crates used to define their own trivial wrappers around DER-encoded bytes. However, in order to avoid inconvenient dependency edges, these were all disconnected. By using a common low-level crate of types with long-term stable API, we hope to avoid the downsides of unnecessary dependency edges while providing interoperability between crates.

Features

  • Interoperability between different crates in the rustls ecosystem
  • Long-term stable API
  • No dependencies
  • Support for no_std contexts, with optional support for alloc

DER and PEM

Many of the types defined in this crate represent DER-encoded data. DER is a binary encoding of the ASN.1 format commonly used in web PKI specifications. It is a binary encoding, so it is relatively compact when stored in memory. However, as a binary format, it is not very easy to work with for humans and in contexts where binary data is inconvenient. For this reason, many tools and protocols use a ASCII-based encoding of DER, called PEM. In addition to the base64-encoded DER, PEM objects are delimited by header and footer lines which indicate the type of object contained in the PEM blob.

This crate's types can be created from both DER and PEM encodings.

Creating new certificates and keys

This crate does not provide any functionality for creating new certificates or keys. However, the rcgen crate can be used to create new certificates and keys.

Cloning private keys

This crate intentionally does not implement Clone on private key types in order to minimize the exposure of private key data in memory.

If you want to extend the lifetime of a PrivateKeyDer<'_>, consider PrivateKeyDer::clone_key(). Alternatively since these types are immutable, consider wrapping the PrivateKeyDer<'_> in a Rc or an Arc.