Home

Awesome

Logo

rustls-native-certs allows rustls to use the platform's native certificate store when operating as a TLS client.

This is supported on Windows, macOS and Linux:

Status

rustls-native-certs is currently in development.

If you'd like to help out, please see CONTRIBUTING.md.

rustls Documentation

Release history:

API

This library exposes a single function with this signature:

pub fn load_native_certs() -> Result<Vec<pki_types::CertificateDer<'static>>, std::io::Error>

On success, this returns a Vec<pki_types::CertificateDer<'static>> loaded with a snapshot of the root certificates found on this platform. This function fails in a platform-specific way, expressed in a std::io::Error.

This function can be expensive: on some platforms it involves loading and parsing a ~300KB disk file. It's therefore prudent to call this sparingly.

Worked example

See examples/google.rs.

Should I use this or webpki-roots?

(Background: webpki-roots is a crate that compiles-in Mozilla's set of root certificates.)

This crate is preferable in many ways to webpki-roots. To sum up the pros and cons:

Pros:

Cons:

License

rustls-native-certs is distributed under the following three licenses:

These are included as LICENSE-APACHE, LICENSE-MIT and LICENSE-ISC respectively. You may use this software under the terms of any of these licenses, at your option.