Java System Properties
Quick Reference Guide


ocsp.enable Java Security Property

The ocsp.enable Java Security Property accepts a boolean value which determines if OCSP (Online Certificate Status Protocol) is used to check if a certificate has been revoked.

Default Value

false

This property's value is either true or false. If true, OCSP checking is enabled when doing certificate revocation checking; if false or not set, OCSP checking is disabled.
via: Java PKI API Programmer's Guide

ocsp.enable Explained

OCSP allows a client to ask a certificate authority's OCSP responder whether a specific certificate has been revoked, instead of downloading an entire certificate revocation list (CRL). Client side OCSP support was added in JDK 5.0.

The ocsp.enable property has no effect unless revocation checking is enabled. For TLS connections that use the default trust manager, revocation checking is disabled by default and must be turned on with the com.sun.net.ssl.checkRevocation system property. When using the CertPathValidator API directly, revocation checking is controlled by PKIXParameters.setRevocationEnabled(). Per Oracle's documentation on client-driven OCSP:

Both steps are necessary. The ocsp.enable setting has no effect unless revocation checking is enabled.

OCSP and CRL Fallback

When revocation checking is enabled and no PKIXRevocationChecker has been supplied programmatically, the JDK's PKIX implementation behaves as follows:

If the revocation status cannot be determined by any method, certificate validation fails.

Setting ocsp.enable

Because ocsp.enable is a security property and not a system property, it cannot be set with a -D command line argument. Instead you can:

Example

Enable OCSP revocation checking (with CRL fallback) for TLS connections:

ocsp.enable=true

Save the above in a file named revocation.security, and then start java with:

java -Djava.security.properties=/path/to/revocation.security -Dcom.sun.net.ssl.checkRevocation=true -Dcom.sun.security.enableCRLDP=true -jar app.jar

Note that com.sun.net.ssl.checkRevocation and com.sun.security.enableCRLDP are system properties, so they are passed with -D rather than placed in the security properties file.

Related Properties

Here are some other Java properties related to networking:

References

Supported Since

Java has supported the ocsp.enable security property since Java 5.

Setting / Reading ocsp.enable at Runtime

You can set ocsp.enable at runtime with the following Java code:

java.security.Security.setProperty("ocsp.enable", "true");

Please note that the ocsp.enable value needs to be specified early, before the internal java classes are loaded that might use this value otherwise it will be ignored.

To read the value of ocsp.enable at runtime, you can use this Java code:

String propertyValue = java.security.Security.getProperty("ocsp.enable");
if (propertyValue != null) {
    System.out.println("ocsp.enable = " + propertyValue);
} else {
    System.out.println("ocsp.enable was null");
}

Setting ocsp.enable on Startup

Be aware that ocsp.enable is not a Java System Property, it is a Java Security Property. Therefore you cannot set it from the command line using -Docsp.enable. You have to set ocsp.enable in the java.security properties file.