From abcd99db585c0bbecd8831c2db028d0ae6608f50 Mon Sep 17 00:00:00 2001 From: Gavin Henry Date: Mon, 18 Nov 2024 10:59:25 +0000 Subject: [PATCH 1/2] Update README.md example to match what's in `lib.rs` --- README.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 6a0844ca..bf6fae2a 100644 --- a/README.md +++ b/README.md @@ -7,14 +7,15 @@ Simple Rust library to generate X.509 certificates. ```Rust -use rcgen::generate_simple_self_signed; +extern crate rcgen; +use rcgen::{generate_simple_self_signed, CertifiedKey}; +// Generate a certificate that's valid for "localhost" and "hello.world.example" let subject_alt_names = vec!["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()); +let CertifiedKey { cert, key_pair } = generate_simple_self_signed(subject_alt_names).unwrap(); +println!("{}", cert.pem()); +println!("{}", key_pair.serialize_pem()); ``` ## Trying it out with openssl From fc2624776eba0cd958604d2a48360944ff11aa77 Mon Sep 17 00:00:00 2001 From: Gavin Henry Date: Mon, 18 Nov 2024 11:23:11 +0000 Subject: [PATCH 2/2] Remove `extern crate` example in docs. --- README.md | 1 - rcgen/src/lib.rs | 1 - 2 files changed, 2 deletions(-) diff --git a/README.md b/README.md index bf6fae2a..8ac9f54b 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,6 @@ Simple Rust library to generate X.509 certificates. ```Rust -extern crate rcgen; use rcgen::{generate_simple_self_signed, CertifiedKey}; // Generate a certificate that's valid for "localhost" and "hello.world.example" let subject_alt_names = vec!["hello.world.example".to_string(), diff --git a/rcgen/src/lib.rs b/rcgen/src/lib.rs index 4f8fb639..e99540a7 100644 --- a/rcgen/src/lib.rs +++ b/rcgen/src/lib.rs @@ -14,7 +14,6 @@ a key pair to call [`CertificateParams::signed_by()`] or [`CertificateParams::se ## Example ``` -extern crate rcgen; use rcgen::{generate_simple_self_signed, CertifiedKey}; # fn main () { // Generate a certificate that's valid for "localhost" and "hello.world.example"