Skip to content

Instantly share code, notes, and snippets.

@bencord0
Created December 25, 2024 23:34
Show Gist options
  • Save bencord0/0528765d4153a87be918e8bb0dfcb656 to your computer and use it in GitHub Desktop.
Save bencord0/0528765d4153a87be918e8bb0dfcb656 to your computer and use it in GitHub Desktop.
Rust script to generate self signed certificates
#!/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