Package com.itextpdf.signatures
Class OcspClientBouncyCastle
java.lang.Object
com.itextpdf.signatures.OcspClientBouncyCastle
- All Implemented Interfaces:
-
IOcspClient
OcspClient implementation using BouncyCastle.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected InputStream
createRequestAndResponse
(X509Certificate checkCert, X509Certificate rootCert, String url) Create OCSP request and get the response for this request, represented asInputStream
.protected static IOCSPReq
generateOCSPRequest
(X509Certificate issuerCert, BigInteger serialNumber) Generates an OCSP request using BouncyCastle.getBasicOCSPResp
(X509Certificate checkCert, X509Certificate rootCert, String url) Gets OCSP response.protected static ICertificateStatus
getCertificateStatus
(byte[] basicOcspRespBytes) Retrieves certificate status from the OCSP response.byte[]
getEncoded
(X509Certificate checkCert, X509Certificate rootCert, String url) Fetch a DER-encoded BasicOCSPResponse from an OCSP responder.
-
Constructor Details
-
OcspClientBouncyCastle
CreatesOcspClient
.- Parameters:
-
verifier
- will be used for response verification. - See Also:
-
-
Method Details
-
getBasicOCSPResp
public IBasicOCSPResp getBasicOCSPResp(X509Certificate checkCert, X509Certificate rootCert, String url) Gets OCSP response. IfOCSPVerifier
was set, the response will be checked.- Parameters:
-
checkCert
- the certificate to check -
rootCert
- parent certificate -
url
- to get the verification - Returns:
-
IBasicOCSPResp
an OCSP response wrapper
-
getEncoded
Fetch a DER-encoded BasicOCSPResponse from an OCSP responder. The method should not throw an exception.Note: do not pass in the full DER-encoded OCSPResponse object obtained from the responder, only the DER-encoded BasicOCSPResponse value contained in the response data.
- Specified by:
-
getEncoded
in interfaceIOcspClient
- Parameters:
-
checkCert
- Certificate to check. -
rootCert
- The parent certificate. -
url
- The URL of the OCSP responder endpoint. If null, implementations can attempt to obtain a URL from the AuthorityInformationAccess extension of the certificate, or from another implementation-specific source. - Returns:
- a byte array containing a DER-encoded BasicOCSPResponse structure or null if one could not be obtained
- See Also:
-
generateOCSPRequest
protected static IOCSPReq generateOCSPRequest(X509Certificate issuerCert, BigInteger serialNumber) throws AbstractOCSPException, IOException, CertificateEncodingException, AbstractOperatorCreationException Generates an OCSP request using BouncyCastle.- Parameters:
-
issuerCert
- certificate of the issues -
serialNumber
- serial number - Returns:
-
IOCSPReq
an OCSP request wrapper - Throws:
-
AbstractOCSPException
- is thrown if any errors occur while handling OCSP requests/responses -
IOException
- signals that an I/O exception has occurred -
CertificateEncodingException
- is thrown if any errors occur while handling OCSP requests/responses -
AbstractOperatorCreationException
- is thrown if any errors occur while handling OCSP requests/responses
-
getCertificateStatus
Retrieves certificate status from the OCSP response.- Parameters:
-
basicOcspRespBytes
- encoded basic OCSP response - Returns:
- good, revoked or unknown certificate status retrieved from the OCSP response, or null if an error occurs.
-
createRequestAndResponse
protected InputStream createRequestAndResponse(X509Certificate checkCert, X509Certificate rootCert, String url) throws IOException, AbstractOperatorCreationException, AbstractOCSPException, CertificateEncodingException Create OCSP request and get the response for this request, represented asInputStream
.- Parameters:
-
checkCert
-X509Certificate
certificate to get OCSP response for -
rootCert
-X509Certificate
root certificate from which OCSP request will be built -
url
-URL
link, which is expected to be used to get OCSP response from - Returns:
-
OCSP response bytes, represented as
InputStream
- Throws:
-
IOException
- if an I/O error occurs -
AbstractOperatorCreationException
- is thrown if any errors occur while handling OCSP requests/responses -
AbstractOCSPException
- is thrown if any errors occur while handling OCSP requests/responses -
CertificateEncodingException
- is thrown if any errors occur while handling OCSP requests/responses
-