System.out.println("OCSP response status is: GOOD="+OCSPUnidResponse.OCSP_GOOD+", REVOKED="+OCSPUnidResponse.OCSP_REVOKED+", UNKNOWN="+OCSPUnidResponse.OCSP_UNKNOWN);
System.out.println("OcspUrl can be set to 'null', in that case the program looks for an AIA extension containing the OCSP URI.");
System.out.println("Just the stress argument gives further info about the stress test.");
return;
}
OCSPUnidResponse response;
Matcher matcher = Pattern.compile("[0-9a-fA-F]{16}").matcher(certfilename);
if (matcher.matches()) {
// It is a certificate serial number instead if a certificate filename
if (ocspUrlFromCLI == null) {
System.out.println("OCSP URL is reqired if a serial number is used.");
System.exit(-1); // NOPMD, it's not a JEE app
}
final OCSPUnidClient client = OCSPUnidClient.getOCSPUnidClient(ksfilename, kspwd, ocspUrlFromCLI, signRequest, ksfilename!=null);
response = client.lookup(new BigInteger(certfilename, 16), getCertFromPemFile(cacertfilename), useGet);
} else {
// It's not a certificate serial number, so treat it as a filename
final Certificate userCert = getCertFromPemFile(certfilename);
String ocspUrl = ocspUrlFromCLI;
if (ocspUrl == null) {
ocspUrl = CertTools.getAuthorityInformationAccessOcspUrl(userCert);
if (ocspUrl == null) {
System.out.println("OCSP URL is required since none was found in the certificate.");
System.exit(-1); // NOPMD, it's not a JEE app
}
}
final OCSPUnidClient client = OCSPUnidClient.getOCSPUnidClient(ksfilename, kspwd, ocspUrl, signRequest, true);
response = client.lookup(userCert, getCertFromPemFile(cacertfilename), useGet);
}
if (response.getErrorCode() != OCSPUnidResponse.ERROR_NO_ERROR) {
System.out.println("Error querying OCSP server.");
System.out.println("Error code is: "+response.getErrorCode());
}
if (response.getHttpReturnCode() != 200) {
System.out.println("Http return code is: "+response.getHttpReturnCode());
}
if (response.getResponseStatus() == 0) {
System.out.print("OCSP return value is: "+response.getStatus()+" (");
switch (response.getStatus()) {
case OCSPUnidResponse.OCSP_GOOD: System.out.println("good)"); break;
case OCSPUnidResponse.OCSP_REVOKED: System.out.println("revoked)"); break;
case OCSPUnidResponse.OCSP_UNKNOWN: System.out.println("unknown)"); break;
}
System.out.println("producedAt: " + response.getProducedAt() + " thisUpdate: " + response.getThisUpdate() + " nextUpdate: " + response.getNextUpdate());
if (response.getFnr() != null) {
System.out.println("Returned Fnr is: "+response.getFnr());
}
} else {
System.out.print("OCSP response status is: "+response.getResponseStatus()+" (");
switch (response.getResponseStatus()) {
case OCSPRespGenerator.MALFORMED_REQUEST: System.out.println("malformed request)"); break;
case OCSPRespGenerator.INTERNAL_ERROR: System.out.println("internal error"); break;
case OCSPRespGenerator.TRY_LATER: System.out.println("try later)"); break;
case OCSPRespGenerator.SIG_REQUIRED: System.out.println("signature required)"); break;
case OCSPRespGenerator.UNAUTHORIZED: System.out.println("unauthorized)"); break;