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");
}
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();
}
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();
}
Aggregations