mirror of
https://git.proxmox.com/git/proxmox-perl-rs
synced 2025-07-01 13:54:53 +00:00
22 lines
640 B
Rust
22 lines
640 B
Rust
#[perlmod::package(name = "PMG::RS::CSR")]
|
|
pub mod export {
|
|
use std::collections::HashMap;
|
|
|
|
use anyhow::Error;
|
|
use serde_bytes::ByteBuf;
|
|
|
|
use proxmox_acme::util::Csr;
|
|
|
|
/// Generates a CSR and its accompanying private key.
|
|
///
|
|
/// The CSR is DER formatted, the private key is a PEM formatted pkcs8 private key.
|
|
#[export]
|
|
pub fn generate_csr(
|
|
identifiers: Vec<&str>,
|
|
attributes: HashMap<String, &str>,
|
|
) -> Result<(ByteBuf, ByteBuf), Error> {
|
|
let csr = Csr::generate(&identifiers, &attributes)?;
|
|
Ok((ByteBuf::from(csr.data), ByteBuf::from(csr.private_key_pem)))
|
|
}
|
|
}
|