Package com.itextpdf.text.pdf.security
Class OCSPVerifier
java.lang.Object
com.itextpdf.text.pdf.security.CertificateVerifier
com.itextpdf.text.pdf.security.RootStoreVerifier
com.itextpdf.text.pdf.security.OCSPVerifier
Class that allows you to verify a certificate against
one or more OCSP responses.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final String
protected static final Logger
The Logger instanceprotected List<org.bouncycastle.cert.ocsp.BasicOCSPResp>
The list of OCSP responses.Fields inherited from class com.itextpdf.text.pdf.security.RootStoreVerifier
rootStore
Fields inherited from class com.itextpdf.text.pdf.security.CertificateVerifier
onlineCheckingAllowed, verifier
-
Constructor Summary
ConstructorsConstructorDescriptionOCSPVerifier
(CertificateVerifier verifier, List<org.bouncycastle.cert.ocsp.BasicOCSPResp> ocsps) Creates an OCSPVerifier instance. -
Method Summary
Modifier and TypeMethodDescriptionorg.bouncycastle.cert.ocsp.BasicOCSPResp
getOcspResponse
(X509Certificate signCert, X509Certificate issuerCert) Gets an OCSP response online and returns it if the status is GOOD (without further checking).boolean
isSignatureValid
(org.bouncycastle.cert.ocsp.BasicOCSPResp ocspResp, Certificate responderCert) Checks if an OCSP response is genuinevoid
isValidResponse
(org.bouncycastle.cert.ocsp.BasicOCSPResp ocspResp, X509Certificate issuerCert) Verifies if an OCSP response is genuine If it doesn't verify against the issuer certificate and response's certificates, it may verify using a trusted anchor or cert.verify
(X509Certificate signCert, X509Certificate issuerCert, Date signDate) Verifies if a a valid OCSP response is found for the certificate.boolean
verify
(org.bouncycastle.cert.ocsp.BasicOCSPResp ocspResp, X509Certificate signCert, X509Certificate issuerCert, Date signDate) Verifies a certificate against a single OCSP responseboolean
verifyResponse
(org.bouncycastle.cert.ocsp.BasicOCSPResp ocspResp, X509Certificate issuerCert) Deprecated.Methods inherited from class com.itextpdf.text.pdf.security.RootStoreVerifier
setRootStore
Methods inherited from class com.itextpdf.text.pdf.security.CertificateVerifier
setOnlineCheckingAllowed
-
Field Details
-
LOGGER
The Logger instance -
id_kp_OCSPSigning
- See Also:
-
ocsps
The list of OCSP responses.
-
-
Constructor Details
-
OCSPVerifier
public OCSPVerifier(CertificateVerifier verifier, List<org.bouncycastle.cert.ocsp.BasicOCSPResp> ocsps) Creates an OCSPVerifier instance.- Parameters:
verifier
- the next verifier in the chainocsps
- a list of OCSP responses
-
-
Method Details
-
verify
public List<VerificationOK> verify(X509Certificate signCert, X509Certificate issuerCert, Date signDate) throws GeneralSecurityException, IOException Verifies if a a valid OCSP response is found for the certificate. If this method returns false, it doesn't mean the certificate isn't valid. It means we couldn't verify it against any OCSP response that was available.- Overrides:
verify
in classRootStoreVerifier
- Parameters:
signCert
- the certificate that needs to be checkedissuerCert
- its issuersignDate
- the date the certificate needs to be valid- Returns:
- a list of
VerificationOK
objects. The list will be empty if the certificate couldn't be verified. - Throws:
GeneralSecurityException
IOException
- See Also:
-
verify
public boolean verify(org.bouncycastle.cert.ocsp.BasicOCSPResp ocspResp, X509Certificate signCert, X509Certificate issuerCert, Date signDate) throws GeneralSecurityException, IOException Verifies a certificate against a single OCSP response- Parameters:
ocspResp
- the OCSP responsesignCert
- the certificate that needs to be checkedissuerCert
- the certificate of CAsignDate
- sign date- Returns:
true
, in case successful check, otherwise false.- Throws:
GeneralSecurityException
IOException
-
isValidResponse
public void isValidResponse(org.bouncycastle.cert.ocsp.BasicOCSPResp ocspResp, X509Certificate issuerCert) throws GeneralSecurityException, IOException Verifies if an OCSP response is genuine If it doesn't verify against the issuer certificate and response's certificates, it may verify using a trusted anchor or cert.- Parameters:
ocspResp
- the OCSP responseissuerCert
- the issuer certificate- Throws:
GeneralSecurityException
IOException
-
verifyResponse
@Deprecated public boolean verifyResponse(org.bouncycastle.cert.ocsp.BasicOCSPResp ocspResp, X509Certificate issuerCert) Deprecated.Verifies if the response is valid. If it doesn't verify against the issuer certificate and response's certificates, it may verify using a trusted anchor or cert. NOTE. UseisValidResponse()
instead.- Parameters:
ocspResp
- the response objectissuerCert
- the issuer certificate- Returns:
- true if the response can be trusted
-
isSignatureValid
public boolean isSignatureValid(org.bouncycastle.cert.ocsp.BasicOCSPResp ocspResp, Certificate responderCert) Checks if an OCSP response is genuine- Parameters:
ocspResp
- the OCSP responseresponderCert
- the responder certificate- Returns:
- true if the OCSP response verifies against the responder certificate
-
getOcspResponse
public org.bouncycastle.cert.ocsp.BasicOCSPResp getOcspResponse(X509Certificate signCert, X509Certificate issuerCert) Gets an OCSP response online and returns it if the status is GOOD (without further checking).- Parameters:
signCert
- the signing certificateissuerCert
- the issuer certificate- Returns:
- an OCSP response
-