setValidityAdjEx method

void setValidityAdjEx({
  1. int notBeforeDays = 0,
  2. int notBeforeSeconds = 0,
  3. int notAfterDays = 365,
  4. int notAfterSeconds = 0,
})

Sets validity using X509_time_adj_ex for fine-grained control.

Implementation

void setValidityAdjEx({
  int notBeforeDays = 0,
  int notBeforeSeconds = 0,
  int notAfterDays = 365,
  int notAfterSeconds = 0,
}) {
  _ensureUsable();
  final notBeforePtr = _context.bindings.X509_getm_notBefore(_cert);
  final notAfterPtr = _context.bindings.X509_getm_notAfter(_cert);

  if (_context.bindings.X509_time_adj_ex(
        notBeforePtr,
        notBeforeDays,
        notBeforeSeconds,
        nullptr,
      ) ==
      nullptr) {
    throw OpenSslException('X509_time_adj_ex failed for notBefore');
  }

  if (_context.bindings.X509_time_adj_ex(
        notAfterPtr,
        notAfterDays,
        notAfterSeconds,
        nullptr,
      ) ==
      nullptr) {
    throw OpenSslException('X509_time_adj_ex failed for notAfter');
  }
}