Skip to main content

validate_x509_cert_body

Function validate_x509_cert_body 

Source
pub fn validate_x509_cert_body(value: &str) -> ConditionResult
Expand description

Validate an X.509 certificate body per BSI TR-03109-4.

In EDIFACT messages (e.g. ORDERS/REQOTE for Smartmeter gateway config) the certificate body is transmitted as base64-encoded DER — the PEM armoring (-----BEGIN CERTIFICATE----- / -----END CERTIFICATE----- lines) may or may not be present depending on the profile.

This validator performs a structural check only:

  • non-empty
  • composed exclusively of base64 characters (A-Za-z0-9+/=) plus whitespace (\n\r\t and space — PEM lines wrap at 64 chars)
  • decoded length plausible for a DER-encoded X.509 certificate (we allow a loose lower bound — a minimal self-signed cert is ~400 bytes, so the base64 form is ≥ ~540 chars; we use 100 as a sanity floor)

Cryptographic validation (signature, CA chain, TR-03109 certificate extensions) is out of scope for static AHB validation — those require a trust store and runtime context.