generalName method
Implementation
String? generalName({required ASN1Object item}) {
var nameType = item.identifier?.tagNumber().toValue();
if (nameType == null) {
return null;
}
switch (nameType) {
case 0:
String? name;
try {
name = item.sub?.last.sub?.last.value as String?;
} catch (e) {}
return name;
case 1:
case 2:
case 6:
var name = item.value is String ? item.value : null;
return name;
case 4:
return ASN1DistinguishedNames.string(block: item);
case 7:
var ip = item.value is List<int> ? item.value : null;
if (ip != null) {
return ip.map((e) => e.toString()).join(".");
}
break;
case 8:
var value = item.value is String ? item.value : null;
if (value != null) {
try {
var data = utf8.encode(value);
var oid = ASN1DERDecoder.decodeOid(contentData: data);
return oid;
} catch (e) {}
}
break;
default:
return null;
}
return null;
}