Skip to content

Instantly share code, notes, and snippets.

@kb10uy
Created July 19, 2024 20:03
Show Gist options
  • Save kb10uy/46a54f7f629421d756e6c89a1434ce10 to your computer and use it in GitHub Desktop.
Save kb10uy/46a54f7f629421d756e6c89a1434ce10 to your computer and use it in GitHub Desktop.
rcgen で雑に自己署名証明書を生成するやつ
#!/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