25 releases

Uses old Rust 2015

0.8.14 Oct 14, 2021
0.8.11 Apr 28, 2021
0.8.9 Dec 4, 2020
0.8.5 Jun 29, 2020
0.2.0 Jan 10, 2019
Download history 9709/week @ 2021-08-08 8119/week @ 2021-08-15 9262/week @ 2021-08-22 9962/week @ 2021-08-29 9107/week @ 2021-09-05 11164/week @ 2021-09-12 11560/week @ 2021-09-19 11037/week @ 2021-09-26 11188/week @ 2021-10-03 12918/week @ 2021-10-10 13644/week @ 2021-10-17 12153/week @ 2021-10-24 10076/week @ 2021-10-31 10036/week @ 2021-11-07 11486/week @ 2021-11-14 10289/week @ 2021-11-21

42,250 downloads per month
Used in 114 crates (47 directly)


1.5K SLoC


docs crates.io dependency status

Simple Rust library to generate X.509 certificates.

extern crate rcgen;
use rcgen::generate_simple_self_signed;
let subject_alt_names = vec!["hello.world.example".to_string(),

let cert = generate_simple_self_signed(subject_alt_names).unwrap();
// The certificate is now valid for localhost and the domain "hello.world.example"
println!("{}", cert.serialize_pem().unwrap());
println!("{}", cert.serialize_private_key_pem());

Trying it out with openssl

You can do this:

cargo run
openssl x509 -in certs/cert.pem -text -noout

For debugging, pasting the PEM formatted text to this service is very useful.

Trying it out with quinn

You can use rcgen together with the quinn crate. The whole set of commands is:

cargo run
cd ../quinn
cargo run --example server -- --cert ../rcgen/certs/cert.pem --key ../rcgen/certs/key.pem ./
cargo run --example client -- --ca ../rcgen/certs/cert.der https://localhost:4433/README.md


The currently latest stable Rust release is the minimum Rust version that this crate supports. Having a policy reaching further back would make no sense because this crate depends on ring which has this same policy.


This crate is distributed under the terms of both the MIT license and the Apache License (Version 2.0), at your option.

See LICENSE for details.

License of your contributions

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.


~245K SLoC