public class OCSPCertStatusChainVerifier extends ChainVerifier
status_request
extension sent by the client. This class works in the same way as
the parent ChainVerifier
class, except for
that it additionally checks OCSP status information sent by the server.
Since OCSP cannot be handled in a crypto-provider independent way,
using this class requires that you have IAIK-JCE (iaik_jce(_full).jar)
)
in your classpath. Note that by default the standard ChainVerifier
is used for certificate chain
verification. To enable this OCSPCertStatusChainVerifier
set it for your
:
SSLClientContext
SSLClientContext clientContext = new SSLClientContext(); ... OCSPCertStatusChainVerifier ocspCertStatusChainVerifier = new OCSPCertStatusChainVerifier(); clientContext.setChainVerifier(ocspCertStatusChainVerifier);If the server has sent an OCSP certificate_status message, this class -- after having verified the server certificate chain -- checks the provided status information and rejects the server certificate if any of the following conditions occur:
ocsp
ExtendedKeyUsage
extension
(if the response signer is different from the server certificate issuer); or if
the response signer is registered as trusted responder (if trusted responders
have been set).
SingleResponse
for the
server certificate
ChainVerifier
,
CertificateStatusRequest
CACHE_SIZE, cachedCerts, cacheSize, checkServerName, nullTrusted, trustedCerts
Constructor and Description |
---|
OCSPCertStatusChainVerifier()
Creates a new ChainVerifier.
|
Modifier and Type | Method and Description |
---|---|
void |
setAccuracy(long accuracy)
Sets the accuracy for time interval checking.
|
void |
setTrustedResponders(iaik.x509.ocsp.utils.TrustedResponders trustedResponders)
Sets any trusted responders for mapping trust between responders to ca certificates.
|
boolean |
verifyChain(java.security.cert.X509Certificate[] certs,
SSLTransport transport,
int statusType,
byte[] statusRequest,
byte[] statusResponse)
Verifies the server certificate chain.
|
protected boolean |
verifyDelegatedResponderCert(iaik.x509.X509Certificate responderCertificate,
iaik.x509.X509Certificate[] responderCertificates,
iaik.x509.ocsp.ResponderID responderID,
iaik.x509.X509Certificate issuerCertificate,
SSLTransport transport)
Verified the response signer certificate of a delegated OCSP responder.
|
addTrustedCertificate, cacheCertificate, cacheCertificates, clearCachedCertificates, clearTrustedCertificates, dumpCertificateChain, getCertificateChain, getCheckServerName, getIssuerCertificate, getTrustedCertificates, getTrustedCertificatesArray, getTrustedPrincipals, getTrustedPrincipalsArray, isCachedCertificate, isTrustedCertificate, removeTrustedCertificate, setCacheSize, setCheckServerName, size, verifyCertificate, verifyChain, verifyChain, verifyClient, verifyServer
public OCSPCertStatusChainVerifier()
public boolean verifyChain(java.security.cert.X509Certificate[] certs, SSLTransport transport, int statusType, byte[] statusRequest, byte[] statusResponse) throws SSLCertificateRuntimeException
This method works in the same way as the same-named method
of the parent ChainVerifier
class, but additionally
also checks an OCSP cert_status message, if sent from the server in response to
a certificate status_request
extension sent by the client.
The statusRequest
and statusResponse
parameters
are only meaningful on the client side and only if client and server
have agreed that the server shall provide certificate status information
in response to a CertificateStatusRequest
extension sent by the client.
In this case, if both statusRequest
and statusResponse
are
not null
, they represent the (TLS) encoded request
field of a CertificateStatusRequest
TLS extension sent to the server and the (TLS) encoded
response
field of the CertificateStatus
handshake message received from the server (see RFC 4366).
This ChainVerifier then uses this information to check the revocation
status of the server certificate.
verifyChain
in class ChainVerifier
certs
- the certificate chain to be verifiedtransport
- the SSLTransport, maybe required to query for information (e.g. client mode)
and/or printing debug informationstatusType
- the type of the certificate status request sent to the server
(and of the status response received from the server), or
-1
if no status_request extension has been
sent to the server (or we are on the server side)statusRequest
- the (TLS) encoded status request sent to the server, or
null
if no status_request extension has been
sent to the server, or we are on the server sidestatusResponse
- the (TLS) encoded status response of the requested type containing
(revocation) status information for the certificates sent by the server,
or null
if no status response has been sent by the server
(or we are on the server side)SSLCertificateRuntimeException
- maybe used by an application to wrap an exception thrown
by some self-designed ChainVerifier implementationOCSPCertStatusChainVerifier
public void setTrustedResponders(iaik.x509.ocsp.utils.TrustedResponders trustedResponders)
If a basic OCSP response is not signed by the same issuer that has signed the
target certificate it has to be checked if the response signer is authorized to
sign the response. In this case the certificate of the response signer
has to be issued by the issuer of the target certificate and has to
contain the ExtendedKeyUsage
extension indicating the id-kp-OCSPSigning
purpose.
You can use this method to set trusted responders for specifying the set of CAs
for which each responder is trusted.
An OCSP Responder is identified by its ResponderID
.
Each entry contained in the given TrustedResponders
repository maps the ID
of the responder in mind to a CA certificate which has authorized this responder for
signing the response, e.g.:
// serverCerts[0] contains the server certificate for which revocation information shall be requested // serverCerts[0] is signed by serverCerts[1] X509Certificate[] serverCerts = ...; // responder cert is the cert used by the responder for signing a response X509Certificate responderCert = ...; // we want to trust this responder for signing responses for certs issued by serverCerts[1] TrustedResponders trustedResponders = new TrustedResponders(); ResponderID responderID = new ResponderID((Name)responderCert.getSubjectDN()); trustedResponders.addTrustedResponderEntry(responderID, serverCerts[1]); // add to ChainVerifier OCSPCertStatusChainVerifier chainVerifier = new OCSPCertStatusChainVerifier(); ... chainVerifier.setTrustedResponders(trustedResponders);
trustedResponders
- the trusted responderspublic void setAccuracy(long accuracy)
accuracy
- the accuracy (in milliseconds) for time checking; default: 60000 (1 minute)protected boolean verifyDelegatedResponderCert(iaik.x509.X509Certificate responderCertificate, iaik.x509.X509Certificate[] responderCertificates, iaik.x509.ocsp.ResponderID responderID, iaik.x509.X509Certificate issuerCertificate, SSLTransport transport) throws SSLCertificateException
trusted responder
information has been configured, this method checks if the responder
cert does contain an ocsp-signing ExtendedKeyUsage
extension and has been authorized by the server certificate issuer for
signing OCSP responses for the server certificate.
trusted responder
information has been configured, this method prints a WARNING message
if the responder cert has not been issued by the server certificate issuer
or has not been authorized for signing OCSP responses
responderCertificate
- the certificate of the response signerresponderCertificates
- the responder certificates (as contained in the
BasicOCSPResponse); may have to be sortedresponderID
- the responder idissuerCertificate
- the certificate that has issued the server certificate
for which we have got an OCSP responsetransport
- the SSLTransport (used for debugging info)true
if the responder cert has been successfully verified,
false
if it has not been successfully verifiedSSLCertificateException
- if an error occurs while checking the
responder certificate