public final void verify(
PublicKey key)
throws CertificateException, NoSuchAlgorithmException,
InvalidKeyException, NoSuchProviderException, SignatureException
{
Signature signature = null;
if (!c.getSignatureAlgorithm().equals(c.getTBSCertificate().getSignature()))
{
throw new CertificateException("signature algorithm in TBS cert not same as outer cert");
}
try
{
signature = Signature.getInstance(c.getSignatureAlgorithm().getObjectId().getId(), "BC");
}
catch (Exception e)
{
signature = Signature.getInstance(c.getSignatureAlgorithm().getObjectId().getId());
}
signature.initVerify(key);
signature.update(this.getTBSCertificate());
if (!signature.verify(this.getSignature()))
{
throw new InvalidKeyException("Public key presented not for certificate signature");
}
}