Rust · no_std · zero dependencies · from the primary texts
TLS and certificate profiles for German energy market communication
BDEW AS4, BSI TR-03116-3 and BSI TR-02102-2 as checkable data, table by table. Export an OpenSSL configuration, audit it, check every handshake and every SM-PKI certificate, and get the exact rule that breaks.
$ cargo add utility-pki --features x509Four checks, one call each
profile.openssl()? Configure
A ready openssl.cnf section. Every suite, group and signature name verified against OpenSSL.
profile.audit(&offer) Audit
What the standard requires that you do not offer, and what you offer that it forbids.
profile.check(&session) Check the handshake
Version, suite, group, key, mutual TLS and Encrypt-then-MAC, with every violation, not just the first.
profile.check_certificate(&cert) Check the certificate
SM-PKI and AS4 certificate rules from strict DER, plus the MP-ID and the AS4 endpoint URI.
Know why a partner rejects you
AS4 onboarding fails on details spread across four documents: a wildcard in the SAN, a second endpoint URI, a critical CertificatePolicies extension, a test-PKI certificate in production. One call names each one, with the table it comes from.
use utility_pki::profiles::BDEW_AS4;
use utility_pki::x509::Certificate;
let cert = Certificate::from_der(&der)?;
for v in BDEW_AS4.check_certificate(&cert).violations() {
eprintln!("{v}");
}
// 2 URIs in SubjectAltName, exactly 1 required (the AS4 endpoint)
// organisation (O) "SM-Test-PKI-DE", "SM-PKI-DE" required
// extension CertificatePolicies must not be criticalConfigure OpenSSL correctly the first time
OpenSSL 3.2+ is the common library that meets BDEW AS4. The export writes the exact names, mandatory items first, and fails instead of silently dropping one.
let config = BDEW_AS4.openssl()?;
print!("{config}");
// MinProtocol = TLSv1.2
// CipherString = ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:…
// Ciphersuites = TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:TLS_AES_128_CCM_SHA256
// Groups = brainpoolP256r1tls13:brainpoolP384r1tls13:secp256r1:…
// Options = ServerPreference,NoRenegotiation,EncryptThenMac,ExtendedMasterSecretThe profiles
| BDEW AS4 | BSI TR-03116-3 | BSI TR-02102-2 | |
|---|---|---|---|
| For | Market communication (Strom, Gas) | Smart metering PKI: WAN and market | General TLS; IEC 62443 crypto baseline |
| TLS 1.2 suites | 4 ECDHE-ECDSA, all MUST | 2 MUST, 2 SHOULD | 16 (EC)DHE, recommended |
| TLS 1.3 suites | AES-128-GCM, AES-256-GCM, AES-128-CCM | AES-128-GCM MUST, 2 SHOULD | same 3, recommended |
| Groups | brainpoolP256r1/P384r1, secp256r1 | same | NIST, Brainpool, ffdhe |
| Certificate | ECDSA brainpoolP256r1, MP-ID, one endpoint URI, ≤ 2 years | ECDSA brainpoolP256r1, SM-PKI profile | ECDSA ≥ 250 bit, RSA ≥ 3000 bit |
| Mutual TLS · revocation | MUST · CRL only | MUST · CRL only | per application |
Built like a security library
Primary texts only
Each rule cites document, version and table. Nothing is copied from other implementations; what cannot be verified is left out, not guessed.
MUST is not SHOULD
Required and optional items are kept apart, per TLS version. Brainpool code point 26 is not 31, and a mix-up is reported.
Unknown never passes
An unreported group, an unknown curve or extension, bytes that are not strict DER: each is a finding or an error, never a silent pass.
no_std, no deps, no panics
Runs on a Cortex-M without an allocator. CI scans the release build for panic paths and fuzzes the DER reader.
Questions
Which TLS cipher suites does BDEW AS4 require?
All four ECDHE-ECDSA suites of BSI TR-03116-3 for TLS 1.2 (AES-128/256 in CBC and GCM) and all three TLS 1.3 suites (TLS_AES_128_GCM_SHA256, TLS_AES_256_GCM_SHA384, TLS_AES_128_CCM_SHA256). The AS4-Profil 1.2 makes every suite the TR recommends mandatory. Groups are brainpoolP256r1, brainpoolP384r1 and secp256r1; certificates are ECDSA on brainpoolP256r1 from the SM-PKI; mutual TLS and SNI are required.
Can rustls be used for BDEW AS4 or TR-03116-3?
No. Both require a CBC suite in TLS 1.2 and Brainpool curves, and BDEW AS4 also requires AES-CCM in TLS 1.3. rustls offers none of these. OpenSSL 3.2 or later supports all of them; utility-pki exports the matching OpenSSL configuration.
Does IEC 62443 define TLS cipher suites?
No. IEC 62443-4-2 CR 4.3 asks for internationally recognized and proven cryptography and leaves the choice to the integrator. utility-pki ships BSI TR-02102-2, a common European baseline for that choice, and shows how to add the security-level requirements such as mutual authentication and revocation checking.
What does the certificate check verify?
For the SM-PKI TLS certificate: key on brainpoolP256r1, issuer signature algorithm, exactly the extensions TR-03109-4 lists with the right criticality, KeyUsage, ExtendedKeyUsage, cA = FALSE, no wildcards, at most 20 DNS names, and O = SM-PKI-DE. For AS4 additionally: the MP-ID in exactly one OU, exactly one endpoint URI, the .EMT.MAK common name, and at most two years of validity.
Does utility-pki do TLS or validate certificate chains?
No. Your TLS library negotiates and your PKI stack verifies signatures, chains and CRLs. utility-pki judges the configuration, the negotiated session and the certificate content against the standard, and tells you exactly which rule is broken.
Is a passing check a certification?
No. Every rule is taken from the primary text and cites its table, but a passing check is evidence for your own conformity assessment, not a certificate from the BSI, the BDEW or a test lab.
Start with one call
Add the crate, pick the profile your standard names, and check.