utility-pki 0.1.0

TLS and certificate profiles of the German energy sector (BDEW AS4, BSI TR-03116-3, BSI TR-02102-2) as Rust data: check sessions, SM-PKI certificates and OpenSSL configurations
Documentation
//! Print a profile as an openssl.cnf SSL section.
//!
//! `cargo run --example openssl -- bdew-as4`

use utility_pki::profiles::{self, ALL};

fn main() {
    let id = std::env::args().nth(1).unwrap_or_else(|| "bdew-as4".into());
    let Some(profile) = profiles::by_id(&id) else {
        let ids: Vec<&str> = ALL.iter().map(|p| p.id).collect();
        eprintln!("unknown profile {id}; choose one of: {}", ids.join(", "));
        std::process::exit(2);
    };
    match profile.openssl() {
        Ok(config) => {
            println!("# Paste into the section your ssl_conf points to, for example:");
            println!("#   openssl_conf = openssl_init");
            println!("#   [openssl_init]  ssl_conf = ssl_sect");
            println!("#   [ssl_sect]      system_default = tls_profile");
            println!("#   [tls_profile]");
            print!("{config}");
        }
        Err(e) => {
            eprintln!("{id}: {e}");
            std::process::exit(1);
        }
    }
}