Skip to Main Content

Java Security

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Reading a Pem CA and returning a X509 Certificate

843811Jul 14 2004 — edited Jul 29 2004
Hi 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
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 26 2004
Added on Jul 14 2004
1 comment
1,058 views