Created
December 25, 2024 23:34
-
-
Save bencord0/0528765d4153a87be918e8bb0dfcb656 to your computer and use it in GitHub Desktop.
Rust script to generate self signed certificates
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env -S cargo +nightly -Zscript | |
---cargo | |
[package] | |
edition = "2024" | |
[dependencies] | |
rcgen = "0.13.2" | |
--- | |
use rcgen::{ | |
CertificateParams, | |
KeyPair, | |
}; | |
use std::error::Error; | |
fn main() -> Result<(), Box<dyn Error>>{ | |
let key = KeyPair::generate()?; | |
let params = CertificateParams::default(); | |
let cert = params.self_signed(&key)?; | |
println!("{}", cert.pem()); | |
println!("{}", key.serialize_pem()); | |
Ok(()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment