maybeRenew method

  1. @override
Future<bool> maybeRenew()
override

Renews certificates if they are near expiry. Returns true if the securityContext changed and the listener should be rebound. A no-op (returning false) for static providers.

Implementation

@override
Future<bool> maybeRenew() async {
  final certBytes = _read(certificatePath);
  final keyBytes = _read(privateKeyPath);
  if (certBytes == null || keyBytes == null) return false; // missing/partial
  if (_bytesEqual(certBytes, _certBytes) &&
      _bytesEqual(keyBytes, _keyBytes)) {
    return false; // unchanged
  }
  final SecurityContext context;
  try {
    context = _build(certBytes, keyBytes, password);
  } on Object {
    return false; // mid-write / invalid: keep the previous certificate
  }
  _context = context;
  _certBytes = certBytes;
  _keyBytes = keyBytes;
  return true;
}