Created
July 19, 2024 20:03
-
-
Save kb10uy/46a54f7f629421d756e6c89a1434ce10 to your computer and use it in GitHub Desktop.
rcgen で雑に自己署名証明書を生成するやつ
This file contains 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 rust-script | |
//! ```cargo | |
//! [dependencies] | |
//! rcgen = "0.13.1" | |
//! ``` | |
use std::{env::args, process::exit}; | |
use rcgen::{CertifiedKey, generate_simple_self_signed}; | |
fn main() { | |
let mut args: Vec<_> = args().collect(); | |
if args.len() <= 1 { | |
eprintln!("specify at least one domain"); | |
exit(1); | |
} | |
args.remove(0); | |
eprintln!("generating self-signed certificate for {args:?}\n"); | |
let CertifiedKey { cert, key_pair } = generate_simple_self_signed(args).expect("failed to generate certificate"); | |
println!("{}", cert.pem()); | |
println!("{}", key_pair.serialize_pem()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment