Function rcgen::generate_simple_self_signed
source · pub fn generate_simple_self_signed(
subject_alt_names: impl Into<Vec<String>>
) -> Result<Certificate, Error>
Expand description
KISS function to generate a self signed certificate
Given a set of domain names you want your certificate to be valid for, this function fills in the other generation parameters with reasonable defaults and generates a self signed certificate as output.
§Example
extern crate rcgen;
use rcgen::generate_simple_self_signed;
let subject_alt_names :&[_] = &["hello.world.example".to_string(),
"localhost".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());