Not able to read otherName value in Subject Alternativate Names of X509 certificate

65 views
Skip to first unread message

Dheeram Kallem

unread,
Oct 20, 2011, 11:18:15 AM10/20/11
to DidiSoft Forum
Hello Friends,

I am using bouncycastle java api to read X509 certificate. I need to
read the values of otherName.

Below is the code snippet that I am using:

private static void getAlternativeName(byte[] extVal) throws
CertificateParsingException {
try {
byte[] extnValue =
DEROctetString.getInstance(ASN1Object.fromByteArray(extVal)).getOctets();
Enumeration it =
DERSequence.getInstance(ASN1Object.fromByteArray(extnValue)).getObjects();
while (it.hasMoreElements()) {
GeneralName genName =
GeneralName.getInstance(it.nextElement());
switch (genName.getTagNo()) {
case GeneralName.otherName :
DERObject derObj = genName.getName().getDERObject();
System.out.println("Name ->" + derObj.getClass().getName());
//Above line is giving org.bouncycastle.asn1.DERSequence class.
System.out.println("In Other Name -> " +
genName.getName().getDERObject().toString());
//Above line is printing [1.3.6.1.4.1.311.20.2.3, [0]AB...@GMAIL.COM]
// AND [2.16.840.1.101.3.6.6,
[0]#d4081858210c2c224d15cda1685a010c090211a2840810d7fc]
break;
default :
throw new IOException("Bad tag number: " + genName.getTagNo());
}
}
} catch (Exception e) {
throw new CertificateParsingException(e.getMessage());
}
}

As commented above I want to read the value AB...@GMAIL.COM.
I tried all possible ways but could not able to do it.

Can someone let me know how can I read the value as a string.

Thanks,
Dheeram

didisoft

unread,
Oct 20, 2011, 11:23:30 AM10/20/11
to DidiSoft Forum
Hello Dheeram,

Unfortunately we cannot help as this is the support forum for DidiSoft
OpenPGP Libraries for Java and .NET.
I will suggestt you to post your question on the www.bouncycastle.org
forums.

Can you tell me how did you found our forum?

Cheers,
Peter Kalef
Reply all
Reply to author
Forward
0 new messages