subject method

String? subject({
  1. String? oid,
  2. ASN1DistinguishedNames? dn,
})

Implementation

String? subject({String? oid, ASN1DistinguishedNames? dn}) {
  if (oid == null && dn != null) {
    oid = dn.oid();
  }
  if (oid != null) {
    var subjectBlock = block1?.atIndex(X509BlockPosition.subject);
    if (subjectBlock != null) {
      var oidBlock = subjectBlock.findOid(oidValue: oid);
      if (oidBlock != null) {
        var sub = oidBlock.parent?.sub;
        if (sub != null && sub.length > 0 && sub.last.value is String) {
          return sub.last.value;
        } else {
          return null;
        }
      }
    }
  }
  return null;
}