Code example for CertificateException

0
        throws CertificateException, NoSuchAlgorithmException,  
            SignatureException, InvalidKeyException 
    { 
        if (!isAlgIdEqual(c.getSignatureAlgorithm(), c.getTBSCertificate().getSignature()))
        { 
            throw new CertificateException("signature algorithm in TBS cert not same as outer cert");
        } 
 
        DEREncodable params = c.getSignatureAlgorithm().getParameters();
 
        // TODO This should go after the initVerify? 
        X509SignatureUtil.setSignatureParameters(signature, params);
 
        signature.initVerify(key);
 
        signature.update(this.getTBSCertificate());
 
        if (!signature.verify(this.getSignature()))
        { 
            throw new InvalidKeyException("Public key presented not for certificate signature");
        }