You can read the certificate in a PEM file using BouncyCastle PEMReader . If the content is an X.509 certificate, you should get an instance X509Certificateand verify it as you want.
EDIT . Here is the code (I haven’t tried it):
PublicKey publicKey = ...;
PEMReader reader = new PEMReader(new FileReader("/path/to/file.pem"));
Object pemObject = reader.readObject();
if (pemObject instanceof X509Certificate) {
X509Certificate cert = (X509Certificate)pemObject;
cert.checkValidity();
cert.verify(publicKey);
}
(Of course, as with any I / O, you need to close the reader, perhaps with try / finally.)
, checkValidity verify : , .