first commit
This commit is contained in:
28
examples/generate-server-cert.rs
Normal file
28
examples/generate-server-cert.rs
Normal file
@@ -0,0 +1,28 @@
|
||||
use std::io::{Write, stdout};
|
||||
|
||||
use clap::Parser;
|
||||
use der::{EncodePem, pem::LineEnding};
|
||||
use mac_address::MacAddress;
|
||||
use p256::pkcs8::EncodePrivateKey;
|
||||
use rsa::rand_core::OsRng;
|
||||
|
||||
use bifrost::{error::ApiResult, server::certificate};
|
||||
|
||||
#[derive(Debug, Parser)]
|
||||
struct Cli {
|
||||
mac: MacAddress,
|
||||
}
|
||||
|
||||
fn main() -> ApiResult<()> {
|
||||
let args = Cli::parse();
|
||||
|
||||
let secret_key = p256::SecretKey::random(&mut OsRng);
|
||||
let cert = certificate::generate(&secret_key, args.mac)?;
|
||||
|
||||
let mut out = stdout().lock();
|
||||
|
||||
out.write_all(secret_key.to_pkcs8_pem(LineEnding::LF)?.as_bytes())?;
|
||||
out.write_all(cert.to_pem(LineEnding::LF)?.as_bytes())?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
Reference in New Issue
Block a user