// If we didn't pass a url to the constructor and the cert does not have the URL, we will fail...
OCSPUnidResponse ret = new OCSPUnidResponse();
ret.setErrorCode(OCSPUnidResponse.ERROR_NO_OCSP_URI);
return ret;
}
final OCSPReqGenerator gen = new OCSPReqGenerator();
final CertificateID certId = new CertificateID(CertificateID.HASH_SHA1, (X509Certificate)cacert, serialNr);
// System.out.println("Generating CertificateId:\n"
// + " Hash algorithm : '" + certId.getHashAlgOID() + "'\n"
// + " CA certificate\n"
// + " CA SubjectDN: '" + cacert.getSubjectDN().getName() + "'\n"
// + " SerialNumber: '" + cacert.getSerialNumber().toString(16) + "'\n"
// + " CA certificate hashes\n"
// + " Name hash : '" + new String(Hex.encode(certId.getIssuerNameHash())) + "'\n"
// + " Key hash : '" + new String(Hex.encode(certId.getIssuerKeyHash())) + "'\n");
gen.addRequest(certId);
if (!useGet) {
// Add a nonce to the request
gen.setRequestExtensions(this.extensions);
}
final OCSPReq req;
if ( this.signKey!=null ) {
final X509Certificate localCertChain[] = this.certChain!=null ? this.certChain : new X509Certificate[] {(X509Certificate)cacert};
gen.setRequestorName(localCertChain[0].getSubjectX500Principal());
req = gen.generate("SHA1withRSA", this.signKey, localCertChain, "BC");
} else {
req = gen.generate();
}
// write request if directory exists.
File ocspReqDir = new File(requestDirectory);
if ( ocspReqDir.isDirectory() ) {
OutputStream os = new FileOutputStream(new File( ocspReqDir, serialNr.toString()));