I'm trying to work with Digital IDs from Verisign for S/MIME. I must however be doing something very wrong as I'm not getting very far.
I downloaded from Verisign the recipient's Certificate/Digital ID.
So far so good, I can use CertificateFactory to load in the file.
Problem I'm having is that I can't verify the Certificate. The error message is:
Exception in thread "main" java.security.SignatureException: Signature does not match.
at sun.security.x509.X509CertImpl.verify(X509CertImpl.java:400)
at sun.security.x509.X509CertImpl.verify(X509CertImpl.java:363)
at TestCertificate.main(TestCertificate.java:23)
Here's the code snippet I'm using:
String filename = "base64.cer";
CertificateFactory cf = CertificateFactory.getInstance("X.509");
FileInputStream fis = new FileInputStream(filename);
BufferedInputStream bis = new BufferedInputStream(fis);
Certificate cert = null;
while (bis.available() > 0)
{
cert = cf.generateCertificate(bis);
System.out.println(cert.toString());
}
PublicKey key = cert.getPublicKey();
cert.verify(key);
Why wouldn't a certificate verify?