Reading a Pem CA and returning a X509 Certificate
843811Jul 14 2004 — edited Jul 29 2004Hi all!
I recieved a method to read a pem file with bouncy castle and retrieve a X509 Certificate, but it doesnt working...
here is the code:
private X509Certificate readerPEM(byte[] cert) {
//Transforma o array de bytes em String
ByteArrayInputStream btCert = new ByteArrayInputStream(cert);
String strCert = btCert.toString();
BufferedReader fRd = new BufferedReader(new StringReader(strCert));
PEMReader pemRd = new PEMReader(fRd);
Object o;
try {
if ((o = pemRd.readObject()) != null) {
if (o instanceof X509Certificate) {
return (X509Certificate) o;
} else {
return null;
}
}
} catch (Exception e) {
return null;
}
return null;
}
i want to learn the right way of read the pem file...
thanks all
Peter