setValidityDates method
Sets validity from explicit UTC dates (UTCTime/GeneralizedTime handled by OpenSSL).
Implementation
void setValidityDates({
required DateTime notBefore,
required DateTime notAfter,
}) {
_ensureUsable();
final notBeforePtr = _context.bindings.X509_getm_notBefore(_cert);
final notAfterPtr = _context.bindings.X509_getm_notAfter(_cert);
final nbUtc = notBefore.toUtc();
final naUtc = notAfter.toUtc();
final nbEpoch = nbUtc.millisecondsSinceEpoch ~/ 1000;
final naEpoch = naUtc.millisecondsSinceEpoch ~/ 1000;
if (_context.bindings.ASN1_TIME_set(notBeforePtr, nbEpoch) == nullptr) {
throw OpenSslException('ASN1_TIME_set failed for notBefore');
}
if (_context.bindings.ASN1_TIME_set(notAfterPtr, naEpoch) == nullptr) {
throw OpenSslException('ASN1_TIME_set failed for notAfter');
}
}