JcaDigestCalculatorProviderBuilder digestCalculatorProviderBuilder = new JcaDigestCalculatorProviderBuilder();
digestCalculatorProviderBuilder.setProvider(BouncyCastleProviderHelper.PROVIDER_NAME);
DigestCalculatorProvider digestCalculatorProvider = digestCalculatorProviderBuilder.build();
DigestCalculator digestCalculator = digestCalculatorProvider.get(CertificateID.HASH_SHA1);
BasicOCSPRespBuilder builder = new BasicOCSPRespBuilder(keyInfo, digestCalculator);
Extension ocspNonce = ocspReq.getExtension(OCSPObjectIdentifiers.id_pkix_ocsp_nonce);
if (ocspNonce != null) {
builder.setResponseExtensions(new Extensions(new Extension[] { ocspNonce }));
}
Req[] list = ocspReq.getRequestList();
for (Req req : list) {
CertificateID certificateID = req.getCertID();
BigInteger serialNumber = certificateID.getSerialNumber();
RevokeReason reason = request.getValidator().validate(serialNumber);
if (reason == null) {
builder.addResponse(certificateID, CertificateStatus.GOOD);
} else {
builder.addResponse(certificateID, new RevokedStatus(new Date(), reason.getCode()));
}
}
JcaContentSignerBuilder contentSignerBuilder = new JcaContentSignerBuilder(bcRequest.getSignAlgorithm());
contentSignerBuilder.setProvider(BouncyCastleProviderHelper.PROVIDER_NAME);
ContentSigner contentSigner = contentSignerBuilder.build(bcRequest.getIssuerPrivateKey());
X509CertificateHolder[] chain = new X509CertificateHolder[] { new X509CertificateHolder(bcRequest.getIssuerCertificate().getEncoded()) };
BasicOCSPResp basicResp = builder.build(contentSigner, chain, new Date());
OCSPResp ocspResp = new OCSPRespBuilder().build(OCSPRespBuilder.SUCCESSFUL, basicResp);
OCSPResponse response = new OCSPResponse(ocspResp.getEncoded());
return response;
} catch (Exception e) {