我尝试使用以下代码提取主题目录属性扩展中每个属性的String值,但它显示以下错误: getInstance中的未知对象org.bouncycastle.asn1.DEROctetString
encoded = cert.getExtensionValue(X509Extensions.SubjectDirectoryAttributes.toString()));
X509Extension sdaExt = new X509Extension(sdaCritical,new DEROctetString(encoded));
ASN1Object obj = X509Extension.convertValueToObject(sdaExt);
SubjectDirectoryAttributes sda = SubjectDirectoryAttributes.getInstance(obj);
for(Object attribute: sda.getAttributes()) {
ASN1Set value = ((Attribute)attribute).getAttrValues();
ASN1ObjectIdentifier attrType = ((Attribute)attribute).getAttrType();
if(attrType.toString().equals("1.3.6.1.5.5.7.9.1")) {
access.setDateOfBirth(value.toString());
}
else if(attrType.toString().equals("1.3.6.1.5.5.7.9.2")) {
access.setSubjectDirectoryAttribute(0, value.toString());
}
else if(attrType.toString().equals("1.3.6.1.5.5.7.9.4")) {
access.setSubjectDirectoryAttribute(1, value.toString());
}
else if(attrType.toString().equals("1.3.6.1.5.5.7.9.3")) {
access.setGender(value.toString());
}
我该如何解决这个问题?