setValidityFromStrings method
Sets validity using explicit ASN.1 time strings.
Accepted formats: "YYMMDDHHMMSSZ" (UTCTime) or "YYYYMMDDHHMMSSZ" (GeneralizedTime).
Implementation
void setValidityFromStrings({
required String notBefore,
required String notAfter,
}) {
_ensureUsable();
final notBeforePtr = _context.bindings.X509_getm_notBefore(_cert);
final notAfterPtr = _context.bindings.X509_getm_notAfter(_cert);
final arena = Arena();
try {
final nbPtr = notBefore.toNativeUtf8(allocator: arena);
final naPtr = notAfter.toNativeUtf8(allocator: arena);
final nbOk = _context.bindings.ASN1_TIME_set_string(
notBeforePtr,
nbPtr.cast(),
);
if (nbOk != 1) {
throw OpenSslException('ASN1_TIME_set_string failed for notBefore');
}
final naOk = _context.bindings.ASN1_TIME_set_string(
notAfterPtr,
naPtr.cast(),
);
if (naOk != 1) {
throw OpenSslException('ASN1_TIME_set_string failed for notAfter');
}
} finally {
arena.releaseAll();
}
}