Search in sources :

Example 1 with CertificatePathValidator

use of org.apache.synapse.transport.certificatevalidation.pathvalidation.CertificatePathValidator in project wso2-synapse by wso2.

the class RevocationVerificationManager method verifyRevocationStatus.

/**
 * This method first tries to verify the given certificate chain using OCSP since OCSP verification is
 * faster. If that fails it tries to do the verification using CRL.
 * @param peerCertificates  javax.security.cert.X509Certificate[] array of peer certificate chain from peer/client.
 * @throws CertificateVerificationException
 */
public void verifyRevocationStatus(javax.security.cert.X509Certificate[] peerCertificates) throws CertificateVerificationException {
    X509Certificate[] convertedCertificates = convert(peerCertificates);
    long start = System.currentTimeMillis();
    OCSPCache ocspCache = OCSPCache.getCache();
    ocspCache.init(cacheSize, cacheDelayMins);
    CRLCache crlCache = CRLCache.getCache();
    crlCache.init(cacheSize, cacheDelayMins);
    RevocationVerifier[] verifiers = { new OCSPVerifier(ocspCache), new CRLVerifier(crlCache) };
    for (RevocationVerifier verifier : verifiers) {
        try {
            CertificatePathValidator pathValidator = new CertificatePathValidator(convertedCertificates, verifier);
            pathValidator.validatePath();
            log.info("Path verification Successful. Took " + (System.currentTimeMillis() - start) + " ms.");
            return;
        } catch (Exception e) {
            log.info(verifier.getClass().getSimpleName() + " failed.");
            log.debug("Certificate verification with " + verifier.getClass().getSimpleName() + " failed. ", e);
        }
    }
    throw new CertificateVerificationException("Path Verification Failed for both OCSP and CRL");
}
Also used : CertificatePathValidator(org.apache.synapse.transport.certificatevalidation.pathvalidation.CertificatePathValidator) OCSPCache(org.apache.synapse.transport.certificatevalidation.ocsp.OCSPCache) X509Certificate(java.security.cert.X509Certificate) CRLCache(org.apache.synapse.transport.certificatevalidation.crl.CRLCache) OCSPVerifier(org.apache.synapse.transport.certificatevalidation.ocsp.OCSPVerifier) CRLVerifier(org.apache.synapse.transport.certificatevalidation.crl.CRLVerifier)

Example 2 with CertificatePathValidator

use of org.apache.synapse.transport.certificatevalidation.pathvalidation.CertificatePathValidator in project wso2-synapse by wso2.

the class RevocationVerificationTest method ocspPathValidation.

private void ocspPathValidation(X509Certificate[] certChain) throws Exception {
    OCSPCache ocspCache = OCSPCache.getCache();
    ocspCache.init(5, 5);
    RevocationVerifier verifier = new OCSPVerifier(ocspCache);
    CertificatePathValidator pathValidator = new CertificatePathValidator(certChain, verifier);
    pathValidator.validatePath();
}
Also used : CertificatePathValidator(org.apache.synapse.transport.certificatevalidation.pathvalidation.CertificatePathValidator) OCSPCache(org.apache.synapse.transport.certificatevalidation.ocsp.OCSPCache) OCSPVerifier(org.apache.synapse.transport.certificatevalidation.ocsp.OCSPVerifier)

Example 3 with CertificatePathValidator

use of org.apache.synapse.transport.certificatevalidation.pathvalidation.CertificatePathValidator in project wso2-synapse by wso2.

the class RevocationVerificationTest method crlPathValidation.

private void crlPathValidation(X509Certificate[] certChain) throws Exception {
    CRLCache crlCache = CRLCache.getCache();
    crlCache.init(5, 5);
    RevocationVerifier verifier = new CRLVerifier(crlCache);
    CertificatePathValidator pathValidator = new CertificatePathValidator(certChain, verifier);
    pathValidator.validatePath();
}
Also used : CertificatePathValidator(org.apache.synapse.transport.certificatevalidation.pathvalidation.CertificatePathValidator) CRLCache(org.apache.synapse.transport.certificatevalidation.crl.CRLCache) CRLVerifier(org.apache.synapse.transport.certificatevalidation.crl.CRLVerifier)

Aggregations

CertificatePathValidator (org.apache.synapse.transport.certificatevalidation.pathvalidation.CertificatePathValidator)3 CRLCache (org.apache.synapse.transport.certificatevalidation.crl.CRLCache)2 CRLVerifier (org.apache.synapse.transport.certificatevalidation.crl.CRLVerifier)2 OCSPCache (org.apache.synapse.transport.certificatevalidation.ocsp.OCSPCache)2 OCSPVerifier (org.apache.synapse.transport.certificatevalidation.ocsp.OCSPVerifier)2 X509Certificate (java.security.cert.X509Certificate)1