Search in sources :

Example 26 with CertificationRequest

use of org.bouncycastle.asn1.pkcs.CertificationRequest in project xipki by xipki.

the class CaEmulator method verifyPopo.

private boolean verifyPopo(CertificationRequest csr) {
    ScepUtil.requireNonNull("csr", csr);
    try {
        PKCS10CertificationRequest p10Req = new PKCS10CertificationRequest(csr);
        SubjectPublicKeyInfo pkInfo = p10Req.getSubjectPublicKeyInfo();
        PublicKey pk = generatePublicKey(pkInfo);
        ContentVerifierProvider cvp = getContentVerifierProvider(pk);
        return p10Req.isSignatureValid(cvp);
    } catch (InvalidKeyException | PKCSException | NoSuchAlgorithmException | InvalidKeySpecException ex) {
        LOG.error("could not validate POPO of CSR", ex);
        return false;
    }
}
Also used : PKCS10CertificationRequest(org.bouncycastle.pkcs.PKCS10CertificationRequest) RSAPublicKey(java.security.interfaces.RSAPublicKey) ECPublicKey(java.security.interfaces.ECPublicKey) PublicKey(java.security.PublicKey) DSAPublicKey(java.security.interfaces.DSAPublicKey) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) InvalidKeySpecException(java.security.spec.InvalidKeySpecException) InvalidKeyException(java.security.InvalidKeyException) SubjectPublicKeyInfo(org.bouncycastle.asn1.x509.SubjectPublicKeyInfo) PKCSException(org.bouncycastle.pkcs.PKCSException) ContentVerifierProvider(org.bouncycastle.operator.ContentVerifierProvider)

Aggregations

CertificationRequest (org.bouncycastle.asn1.pkcs.CertificationRequest)17 X509Certificate (java.security.cert.X509Certificate)14 X500Name (org.bouncycastle.asn1.x500.X500Name)12 Date (java.util.Date)10 SubjectPublicKeyInfo (org.bouncycastle.asn1.x509.SubjectPublicKeyInfo)7 CertificateException (java.security.cert.CertificateException)6 CertificationRequestInfo (org.bouncycastle.asn1.pkcs.CertificationRequestInfo)6 Extensions (org.bouncycastle.asn1.x509.Extensions)6 OperationException (org.xipki.ca.api.OperationException)6 IOException (java.io.IOException)5 BigInteger (java.math.BigInteger)5 File (java.io.File)4 InvalidKeySpecException (java.security.spec.InvalidKeySpecException)4 PKCS10CertificationRequest (org.bouncycastle.pkcs.PKCS10CertificationRequest)4 EnrolmentResponse (org.xipki.scep.client.EnrolmentResponse)4 ScepClient (org.xipki.scep.client.ScepClient)4 InvalidKeyException (java.security.InvalidKeyException)3 PrivateKey (java.security.PrivateKey)3 ContentInfo (org.bouncycastle.asn1.cms.ContentInfo)3 Certificate (org.bouncycastle.asn1.x509.Certificate)3