certificates property Null safety

Iterable<X509> certificates

The certification chain of the message.

Implementation

Iterable<X509> get certificates sync* {
  if (_cert == null) {
    return;
  }

  var o = 0;
  while (o < _cert!.valueByteLength!) {
    final c = ASN1Parser(_cert!.valueBytes!.sublist(o)).nextObject();
    yield X509(c as ASN1Sequence);
    o += c.encodedBytes!.lengthInBytes;
  }
}