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