// Not a CVC request, perhaps a PKCS10 request
try {
final PKCS10CertificationRequest pkcs10 = new PKCS10CertificationRequest(requestBytes);
// ret = pkcs10.toString();
final ASN1InputStream ais = new ASN1InputStream(new ByteArrayInputStream(pkcs10.getEncoded()));
final DERObject obj = ais.readObject();
ret = ASN1Dump.dumpAsString(obj);
type = "PKCS#10";
} catch (IOException e1) {
// ignore, move on to certificate decoding
} catch (IllegalArgumentException e1) {
// ignore, move on to certificate decoding
} catch (ClassCastException e2) {
// ignore, move on to certificate decoding
}
} else if (ret != null) {
type = "CVC";
}
if (ret == null) {
// Not a CVC object or PKCS10 request message, perhaps a X.509 certificate?
try {
final Certificate cert = getCert(bytes);
ret = CertTools.dumpCertificateAsString(cert);
type = "X.509";
} catch (Exception e) {
// Not a X.509 certificate either...try to simply decode asn.1
try {
final ASN1InputStream ais = new ASN1InputStream(new ByteArrayInputStream(bytes));
final DERObject obj = ais.readObject();
if (obj != null) {
ret = ASN1Dump.dumpAsString(obj);
type = "ASN.1";
}
} catch (IOException e1) {