public class OCSPConfiguration
extends java.lang.Object
CertID Hashing Algorithm is set to SHA256To ensure efficient and reliable configuration of OCSP, the following items should be configured:
1. Any OCSP responder who is trusted is configured by setting the responder's verification
certificate using addResponderCertificates(X509Certificate[]). Multiple Responders
can be trusted by this configuration. For example, if AIA mode is enabled setAIAChecking(boolean)
then the certificate which signed the OCSP response may need to be authorized. If that is the case, then
having this certificate listed as a trusted certificate will enable the certificate to be authorized, and
the revocation check will be able to succeed. If this certificate were not trusted, then the certificate which
signed the OCSP request must be contained in the OCSP response, must be issued by the CA certificate that issued
the cerificate being check for revocation, and must contain the id-ad-ocspSigning in an extendedKeyUsage extension.
See RFC 2560
section 4.2.2.2 for how this process works
2. The Certificate Authority Distinguished Name list (CADN list) is used to determine whether this OCSPConfiguration should be used to send an OCSP request to the configured responder. Essentially the issuer DN of the certificate being checked for revocation is matched against this list.
3. Either the setAIAChecking(boolean) should be enabled, or the OCSP AccessLocation should be set. The
AccessLocation is set with either the setAccessLocation(GeneralName) or setURLLocation(URL)
methods. The AuthorityInfoAccess certificate extension stores the AccessLocation of the OCSP responder
in the certificate being checked for revocation. However, there may be environments where this
setting should be ignored. If neither setting is enabled, then no revocation checking can be done for
this OCSP configuration. A default OCSP configuration will enable AIA checking.
4. It may be desirable to set the ConnectionTimeout. When the OCSP responder is contacted to determine revocation status, a timeout can be specified to determine the maximum length of time the client will wait for a reply. The default value is 0, which means the Java toolkit will wait forever. To avoid the possibility of the toolkit waiting forever, it is therefore recommended that the client application set a ConnectionTimeout. Under a Java 1.4.x environment, the ConnectTimeout is the maximum length of time in milliseconds which the Java toolkit will allow for connecting and reading data from the OCSP responder. Under Java 1.4.x there is no distinction between the ConnectTimeout and ReadTimeout values. Under a Java 1.5.x or later environment, the ConnectTimeout is the maximum length of time in milliseonds which the Java toolkit will allow for connection to the OCSP responder.
5. It may be desirable to set the ReadTimeout. Under a Java 1.4.x environment, setting the ReadTimeout value has no effect on the behaviour of the toolkit. Under a Java 1.5.x or later environment, the ReadTimeout is the maximum length of time in milliseconds which the Java toolkit will allow for reading data from the OCSP responder. The default timeout value is 0, which means there is no limit.
| Modifier and Type | Field and Description |
|---|---|
static int |
INCLUDE_ALL_CERTS |
static int |
INCLUDE_NONE |
static int |
INCLUDE_VERIFICATION_CERT |
static int |
MAX_RETRIES
Limit amout of retries, as a very large number would cause the toolkit to hang, and
could be used for a denial of service attack.
|
| Constructor and Description |
|---|
OCSPConfiguration()
The default constructor.
|
OCSPConfiguration(GeneralName accessLocation)
Creates a Default OCSP Configuration with the specified accessLocation.
|
OCSPConfiguration(java.net.URL urlLocation)
Creates a Default OCSP Configuration with the specified URL.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addCADN(Name name)
When a certificate is checked for revocation status, a list of CA Names
is checked against the issuer of the certificate being checked for
revocation.
|
void |
addCADNList(java.util.ArrayList names)
When a a certificate is checked for revocation status, a
list of CA Names is checked against the issuer of the certificate
being checked for revocation.
|
void |
addCADNList(Name[] names)
A Convienance method for adding an Array of Name DNs to the internal
list of CA Names.
|
void |
addResponderCertificate(X509Certificate responderCert)
Adds a trusted verficiation certificate of an OCSP responder to the
list of trusted responder certificates for this OCSPConfiguration.
|
void |
addResponderCertificates(java.util.ArrayList certificates)
Adds a List of trusted verification certificates for each OCSP responder
which should be trusted by this OCSPConfiguration.
|
void |
addResponderCertificates(X509Certificate[] responderCerts)
Adds an array of trusted verficiation certificates for each OCSP responder
which should be trusted by this OCSPConfiguration.
|
static java.net.URL |
convertAccessLocation(GeneralName accessLocation)
Converts an AccessLocation specified as a General name into a
URL object. |
boolean |
equals(java.lang.Object obj)
Tests whether each parameter configured in this OCSPConfiguration object
is equal to each parameter configured in the provided OCSPConfiguration object.
|
GeneralName |
getAccessLocation() |
boolean |
getAIAChecking() |
java.util.ArrayList |
getCADNList() |
Name[] |
getCADNs() |
AlgorithmID |
getCertIDHashAlgorithm()
Returns the Hashing algorithm used to identify the certificate in
the ASN.1 CertID structure.
|
int |
getConnectTimeout() |
javax.net.ssl.HostnameVerifier |
getHostnameVerifier()
Return the HostnameVerifier to use when an OCSP request
over HTTPS is used
|
boolean |
getIncludeAcceptableResponses() |
boolean |
getIncludeRequestorName() |
int |
getIncludeVerificationChain() |
int |
getReadTimeout() |
java.util.ArrayList |
getResponderCertificateList()
Returns the trusted responders verification certificate list if it was
set.
|
X509Certificate[] |
getResponderCertificates()
Returns the trusted responders verfication certificate list if it was
set.
|
int |
getRetries() |
AlgorithmID |
getSigningAlgorithm() |
boolean |
getSignRequest()
Convienance method which returns whether or not the request
should be signed.
|
javax.net.ssl.SSLSocketFactory |
getSSLSocketFactory()
Return the SSLSocketFactory used when an OCSP request
over HTTPS is used:
|
java.net.URLStreamHandler |
getStreamHandler()
Return the URLStreamHandler to use when an OCSP request
over HTTPS is used
|
java.net.URL |
getURLLocation() |
boolean |
getUseNonce() |
int |
hashCode()
Returns a hash code value for the object.
|
void |
removeCADN(Name cadn)
Removes a CA DN from the list of CA DN's which this responder is
trusted.
|
void |
removeResponderCertificate(X509Certificate responderCert)
Removes a trusted Responder verification certificate from the list of
trusted responder verification certificates.
|
void |
setAccessLocation(GeneralName accessLocation)
Sets the Access location of the OCSP Responder.
|
void |
setAIAChecking(boolean useAIA)
This parameter will enable the OCSP configuration to
use the Authority Information Access (AIA) Certificate extension id-ad-ocsp
for checking revocation.
|
void |
setCertIDHashAlgorithm(java.lang.String alg)
Sets the Hashing algorithm used to identify the certificate in
the ASN.1 CertID structure.
|
void |
setConnectTimeout(int ConnectTimeout)
Under a Java 1.4.x environment, the ConnectTimeout is the maximum length of time in milliseconds
which the Java toolkit will allow for connecting and reading data from the OCSP responder.
|
void |
setIncludeAcceptableResponses(boolean includeRequest)
Allows inclusion of the AcceptableResponseTypes extension to be included in the
message.
|
void |
setIncludeRequestorName(boolean include)
RFC 2560 section 4 states the requestorName is optional.
|
void |
setReadTimeout(int ReadTimeout)
Under a Java 1.4.x environment, setting the ReadTimeout value has no effect on the behaviour of the toolkit.
|
void |
setRetries(int retry)
Sets the number of times that an OCSP request will be attempted to be set
The minimum is 0, maximum is defined by MAX_RETRIES
|
void |
setSignRequest(boolean isSigned,
int includeCerts,
java.lang.String signaturealg)
This method is used to set whether the OCSP Request is signed.
|
void |
setSSLConfiguration(javax.net.ssl.SSLSocketFactory factory,
javax.net.ssl.HostnameVerifier hostnameVerifier,
java.net.URLStreamHandler streamHandler)
Set the SSL Connection parameters to use when the OCSP access location is an HTTPS
location
|
void |
setURLLocation(java.net.URL url)
Sets the Access location of the OCSP Responder.
|
void |
setUseNonce(boolean useNonce)
Allows sending of the Nonce OCSP request extension.
|
OCSPConfiguration |
shallowCopy()
Makes a shallow copy of this object.
|
public static final int MAX_RETRIES
public static final int INCLUDE_VERIFICATION_CERT
public static final int INCLUDE_ALL_CERTS
public static final int INCLUDE_NONE
public OCSPConfiguration()
CertID Hashing Algorithm is set to SHA256public OCSPConfiguration(GeneralName accessLocation)
CertID Hashing Algorithm is set to SHA256accessLocation - The AccessLocation of the OCSP Responderpublic OCSPConfiguration(java.net.URL urlLocation)
The rest of the configuration will be set as follows:
CertID Hashing Algorithm is set to SHA256urlLocation - The URL location of the OCSP Responderpublic static java.net.URL convertAccessLocation(GeneralName accessLocation)
URL object.accessLocation - public void addCADN(Name name)
The List of CA DN's is stored in an ArrayList, this method adds the given Name into the ArrayList. If the item is already in the list it is not added.
name - The DN's of the CA's which this responder is trusted. If this
is not set, then this responder can be used to check all
certificates that are requested.public void addCADNList(java.util.ArrayList names)
This method adds the list of Names in the given arrayList into the internal List of Names.
names - The DN's of the CA's which this responder is trusted.
If this is not set, then this responder can be used to check
all certificates that are requested.public void addCADNList(Name[] names)
When a a certificate is checked for revocation status, this list of CA Names is checked against the issuer of the certificate being checked for revocation.
The List of CA DN's is stored in an ArrayList, so this method simply adds the given Name array into the ArrayList. If the item is already in the list it is not added.
names - The DN's of the CA's which this responder is trusted.
If this is not set, then this responder can be used to check
all certificates that are requested.public void addResponderCertificate(X509Certificate responderCert)
If there are no trusted responder certificates available, then the the toolkit will attempt to verify the OCSP response with the trusted credentials at its disposal. If an OCSP response cannot be verified, then the revocation status of the certificate cannot be verified. Therefore configuration of the list of responder certificates is recommended.
responderCert - the responders trusted verification certificatepublic void addResponderCertificates(java.util.ArrayList certificates)
If there are no trusted responder certificates available, then the toolkit will attempt to verify the OCSP response with the trusted credentials at its disposal. If an OCSP response cannot be verified, then the revocation status of the certificate cannot be verified. Therefore configuration of the list of responder certificates is recommended.
certificates - an ArrayList containing certificatepublic void addResponderCertificates(X509Certificate[] responderCerts)
If there are no trusted responder certificates available, then the the toolkit will attempt to verify the OCSP response with the trusted credentials at its disposal. If an OCSP response cannot be verified, then the revocation status of the certificate cannot be verified. Therefore configuration of the list of responder certificates is recommended.
responderCerts - the OCSP responder(s) trusted verification certificate(s)public boolean equals(java.lang.Object obj)
equals in class java.lang.Objecttrue if all the configured parameters are equal
false otherwiseObject.equals(java.lang.Object)public GeneralName getAccessLocation()
public boolean getAIAChecking()
public java.util.ArrayList getCADNList()
public Name[] getCADNs()
public AlgorithmID getCertIDHashAlgorithm()
public int getConnectTimeout()
public boolean getIncludeAcceptableResponses()
public boolean getIncludeRequestorName()
public int getReadTimeout()
public java.util.ArrayList getResponderCertificateList()
public X509Certificate[] getResponderCertificates()
public int getRetries()
public AlgorithmID getSigningAlgorithm()
public int getIncludeVerificationChain()
public boolean getSignRequest()
public java.net.URL getURLLocation()
public boolean getUseNonce()
public int hashCode()
hashCode in class java.lang.ObjectObject.hashCode()public void removeCADN(Name cadn)
cadn - the CADN to remove.public void removeResponderCertificate(X509Certificate responderCert)
responderCert - the certificate to removepublic void setAccessLocation(GeneralName accessLocation)
In order to convey to OCSP clients a well-known point of information access, CAs SHALL provide the capability to include the AuthorityInfoAccess extension (defined in [RFC3280], section 4.2.2.1) in certificates that can be checked using OCSP. Alternatively, the accessLocation for the OCSP provider may be configured locally at the OCSP client. CAs that support an OCSP service, either hosted locally or provided by an Authorized Responder, MUST provide for the inclusion of a value for a uniformResourceIndicator (URI) accessLocation and the OID value id-ad-ocsp for the accessMethod in the AccessDescription SEQUENCE. The value of the accessLocation field in the subject certificate defines the transport (e.g. HTTP) used to access the OCSP responder and may contain other transport dependent information (e.g. a URL).This method stores the accessLocation in both GeneralName format, and URL format. If the accessLocation has already been set, it will be overridden with the new value. If the AccessMethod does not represent a URL, then the value of the AccessMethod and URL will be null.
accessLocation - The accessLocation of the OCSP responderpublic void setAIAChecking(boolean useAIA)
useAIA - A value of true will enable AIA checking. A value of false
will disable AIA checking. The default configuration is set to true.public void setCertIDHashAlgorithm(java.lang.String alg)
Currently the following hashing algorithms are allowed:
alg - The Hashing algorithm. The Default is SHA-256.public void setConnectTimeout(int ConnectTimeout)
Under a Java 1.5.x or later environment, the ConnectTimeout is the maximum length of time in milliseonds which the Java toolkit will allow for connection to the OCSP responder. The default timeout value is 0, which means there is no limit.
It is recommended that this value be set to an approperiate timeout value.
ConnectTimeout - the ConnectTimeout in millisecondspublic void setIncludeAcceptableResponses(boolean includeRequest)
AcceptableResponseTypes - (RFC 2560) specifies the AcceptableResponses extension for allowing an OCSP client to specify the kinds of response types it understands.
This extension is included as one of the requestExtensions in
requests. The OIDs included in AcceptableResponses
are the OIDs of the various response types this client can accept
(e.g., id-pkix-ocsp-basic).
The "basic" response type BasicOCSPResponse.responseType is the only standardized type, so the presence of this extension is unnecessary in the general case.
includeRequest - true indicates the extension will be included, otherwise the
extension will not be includedpublic void setIncludeRequestorName(boolean include)
TBSRequest ::= SEQUENCE {
version [0] EXPLICIT Version DEFAULT v1,
requestorName [1] EXPLICIT GeneralName OPTIONAL,
requestList SEQUENCE OF Request,
requestExtensions [2] EXPLICIT Extensions OPTIONAL }
Therefore, this method allows the requestorName to be excluded from
the OCSP request. This exclusion will only be honoured when
OCSP requests are not signed. RFC 2560
states that the requestorName must be included in signed requests.include - should be set to true if the requestorName will be included, false
if the requestorName will be excluded.public void setReadTimeout(int ReadTimeout)
Under a Java 1.5.x or later environment, the ReadTimeout is the maximum length of time in milliseconds which the Java toolkit will allow for reading data from the OCSP responder. The default timeout value is 0, which means there is no limit.
ReadTimeout - the read timeout in millisecondspublic void setRetries(int retry)
retry - the number of OCSP request attemptspublic void setSignRequest(boolean isSigned,
int includeCerts,
java.lang.String signaturealg)
When an OCSP request is signed, RFC 2560 section 4.1.2 states:
The requestor MAY choose to sign the OCSP request. In that case, the signature is computed over the tbsRequest structure. If the request is signed, the requestor SHALL specify its name in the requestorName field. Also, for signed requests, the requestor MAY include certificates that help the OCSP responder verify the requestor's signature in the certs field of Signature.This list of certificates should help the OCSP responder build a path to the OCSP requestor’s certificate. In this implementation, the client has the option of including the signer certificates in one of three ways:
If the request is signed, the requestorName must be set, so if the excludeRequestName() method has been called, it will be ignored.
A string indicating the signing algorithms to be used for signing the request should also be included. If nothing is include, the default "sha256WithRSAEncryption" algorithm will be used. The list of currently supported algorithms is as follows:
isSigned - Boolean value which determines whether the OCSP Request is
signed (true) or whether it is unsigned (false). The default
value is unsigned (false).includeCerts - An optional parameter than used to help the OCSP responder build a
path to the requestorCertificate for certificate validation on the
OCSP server side.signaturealg - The signature algorithm used to signed the request.public void setURLLocation(java.net.URL url)
In order to convey to OCSP clients a well-known point of information access, CAs SHALL provide the capability to include the AuthorityInfoAccess extension (defined in [RFC3280], section 4.2.2.1) in certificates that can be checked using OCSP. Alternatively, the accessLocation for the OCSP provider may be configured locally at the OCSP client. CAs that support an OCSP service, either hosted locally or provided by an Authorized Responder, MUST provide for the inclusion of a value for a uniformResourceIndicator (URI) accessLocation and the OID value id-ad-ocsp for the accessMethod in the AccessDescription SEQUENCE. The value of the accessLocation field in the subject certificate defines the transport (e.g. HTTP) used to access the OCSP responder and may contain other transport dependent information (e.g. a URL).This method stores the URL in both URL and GeneralName format. If the URL has already been set, it will be overridden with the new value. If the URL does not represent a URL, then the value of the URL and AccessMethod will be null.
url - The accessLocation of the OCSP responderpublic void setUseNonce(boolean useNonce)
Nonce -
(RFC 2560) specifies the Nonce
extension for cryptographically binding a request and a response to prevent
replay attacks. It is used only in requests where pre-generated or cached
responses are not acceptable. The nonce is included as one of the
requestExtensions in an OCSPRequest, while in
responses it would be included as
one of the responseExtensions.
Setting this value to true in the OCSPConfiguration will cause the Java toolkit to create a random Nonce value each time an OCSP request is generated. When the OCSP responder responds to a request with the Nonce extension, it must include a copy of the Nonce in the signed response, otherwise the response will be considered invalid. Usage of the nonce therefore forces the OCSP responder to generate a fresh OCSP request, which may result in more timely revocation information.
SingleResponses are not cached when this setting is true.
useNonce - true to indicate Nonce should be used, false if nonce should not be used.
The default setting is false.public void setSSLConfiguration(javax.net.ssl.SSLSocketFactory factory,
javax.net.ssl.HostnameVerifier hostnameVerifier,
java.net.URLStreamHandler streamHandler)
factory - The SSLSocketFactory that will be used to create the socketshostnameVerifier - the HostnameVerifier to use when performing hostname validation
on SSL requestsstreamHandler - The URLStreamHandler that will be used to perform the protocol
side of the connection.public javax.net.ssl.SSLSocketFactory getSSLSocketFactory()
public javax.net.ssl.HostnameVerifier getHostnameVerifier()
public java.net.URLStreamHandler getStreamHandler()
public OCSPConfiguration shallowCopy()
Warning: This object does not make a deep copy of the object! Care must be taken after calling this method as changes to the object could affect the original object.
After this method is called, any calls to add or remove CADN or ResponderCerticate Lists are not safe. These methods make changes to the underlying Arraylist structure.
All other method calls replace existing data in the newly copied object and are therefore safe.