File tree Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change 7
7
Simple Rust library to generate X.509 certificates.
8
8
9
9
``` Rust
10
- use rcgen :: generate_simple_self_signed;
10
+ extern crate rcgen;
11
+ use rcgen :: {generate_simple_self_signed, CertifiedKey };
12
+ // Generate a certificate that's valid for "localhost" and "hello.world.example"
11
13
let subject_alt_names = vec! [" hello.world.example" . to_string (),
12
14
" localhost" . to_string ()];
13
15
14
- let cert = generate_simple_self_signed (subject_alt_names ). unwrap ();
15
- // The certificate is now valid for localhost and the domain "hello.world.example"
16
- println! (" {}" , cert . serialize_pem (). unwrap ());
17
- println! (" {}" , cert . serialize_private_key_pem ());
16
+ let CertifiedKey { cert , key_pair } = generate_simple_self_signed (subject_alt_names ). unwrap ();
17
+ println! (" {}" , cert . pem ());
18
+ println! (" {}" , key_pair . serialize_pem ());
18
19
```
19
20
20
21
## Trying it out with openssl
You can’t perform that action at this time.
0 commit comments