Path: redb-route/redb.Route.As2/Crypto/As2CertificateValidity.cs Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route Page: https://redbase.app/src/dev-2026-12-06/redb-route/redb.Route.As2/Crypto/As2CertificateValidity.cs ---- using System.Security.Cryptography; using System.Security.Cryptography.X509Certificates; namespace redb.Route.As2.Crypto; /// /// Whether a certificate an agreement pins may be used now. The pin says whose key it is; it does not make an expired /// key current (the AS4 connector's rule, after Holodeck and Domibus). Revocation (CRL/OCSP) and chain trust are not /// checked: the pin is the trust, and revocation is a documented gap of this connector. /// internal static class As2CertificateValidity { /// Null when is valid at ; otherwise why not, naming . public static string? Problem(X509Certificate2 certificate, DateTimeOffset now, string role) { ArgumentNullException.ThrowIfNull(certificate); var who = $"{role} {certificate.Subject} ({certificate.Thumbprint})"; var utc = now.UtcDateTime; if (utc < certificate.NotBefore.ToUniversalTime()) return $"{who} is not yet valid: valid from {certificate.NotBefore.ToUniversalTime():O}."; if (utc > certificate.NotAfter.ToUniversalTime()) return $"{who} has expired: valid until {certificate.NotAfter.ToUniversalTime():O}."; return null; } /// Throws when may not be used now. public static void Ensure(X509Certificate2 certificate, string role) { if (Problem(certificate, DateTimeOffset.UtcNow, role) is { } problem) throw new CryptographicException(problem); } }