Skip to content

Commit

Permalink
Update README.md example to match what's in lib.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
ghenry authored and djc committed Nov 18, 2024
1 parent 1b4a355 commit 72369d3
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 72369d3

Please sign in to comment.