22 releases (stable)

new 1.10.1 Dec 13, 2024
1.10.0 Oct 15, 2024
1.9.0 Sep 27, 2024
1.7.0 May 7, 2024
0.2.3 Nov 28, 2023

#80 in Cryptography

Download history 1196145/week @ 2024-08-23 1154725/week @ 2024-08-30 1225719/week @ 2024-09-06 1131006/week @ 2024-09-13 1262774/week @ 2024-09-20 1345313/week @ 2024-09-27 1470995/week @ 2024-10-04 1618277/week @ 2024-10-11 1717541/week @ 2024-10-18 1627623/week @ 2024-10-25 1440421/week @ 2024-11-01 1458697/week @ 2024-11-08 1508329/week @ 2024-11-15 1398135/week @ 2024-11-22 1412017/week @ 2024-11-29 1413801/week @ 2024-12-06

6,015,060 downloads per month
Used in 3,159 crates (136 directly)

MIT/Apache

120KB
2.5K SLoC

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.

Dependencies

~0–255KB