JDK-8300722 : Enhance OCSP, CRL and Certificate Fetch Timeouts
  • Type: CSR
  • Component: security-libs
  • Sub-Component: java.security
  • Priority: P4
  • Status: Closed
  • Resolution: Approved
  • Fix Versions: 21
  • Submitted: 2023-01-20
  • Updated: 2024-10-18
  • Resolved: 2023-05-23
Related Reports
CSR :  
Relates :  
Relates :  
Relates :  
Description
Summary
-------
Allow the existing `com.sun.security.ocsp.timeout`, `com.sun.security.crl.timeout` and `com.sun.security.crl.readtimeout` System properties to be specified in milliseconds by appending "ms" to the end of the numeric value.  In addition three new properties will be introduced.  The first is `com.sun.security.ocsp.readtimeout` which will provide a timeout specifically for the reading of an OCSP response after a connection has been established.  The other two properties are for certificate fetching timeouts based on an X.509 certificate's AIA extension: `com.sun.security.cert.timeout` and `com.sun.security.cert.readtimeout`. All three properties have the same syntax requirements as the existing timeout properties above.  The syntax specifics are detailed in the Solution section.

Problem
-------
The existing property value must be a decimal integer to be interpreted in seconds.  Given the average latency for OCSP, certificate, and CRL fetches can be less than one second it is sensible to allow the user to specify a timeout period with millisecond granularity.  While OCSP and CRLs have timeout properties already, CA issuer certificate fetching can only be done through API calls and no System properties exist as they do for OCSP and CRL fetches.  This would introduce timeout properties that behave in a similar fashion to the OCSP and CRL timeout properties that prevent indefinite stalls during fetches.

Solution
--------

 - Enhance the allowed syntax for the existing `com.sun.security.ocsp.timeout`, `com.sun.security.crl.timeout` and `com.sun.security.crl.readtimeout` as detailed below.
 - Create three new properties `com.sun.security.ocsp.readtimeout`, `com.sun.security.cert.timeout` and `com.sun.security.cert.readtimeout` with the same syntax as those above.
   - `com.sun.security.ocsp.readtimeout` will hold the timeout value for reading an OCSP response after a connection has been established.  The `com.sun.security.crl.timeout` property will now handle only the timeout for establishing the TCP connection to the OCSP responder.  Previously the latter property's timeout value was applied to both kinds of timeouts.  This new property allows users to independently control the two kinds of timeouts similar to how other connect/read timeout property pairs are handled.
   - `com.sun.security.cert.timeout` and `com.sun.security.cert.readtimeout` handle timeouts for establishing the TCP connection and certificate reading, respectively, when following an X.509 certificate's AIA extension.

For all properties, existing and new, the proposed expanded syntax will conform to the following:

 - A decimal integer: This will maintain the existing behavior of being interpreted in seconds.  This ensures backward compatibility.  If a non-numeric or negative value is supplied, the default timeout value of 15 seconds will be applied.  The default value is also the current behavior.
 - A decimal integer ending in "s" (case-insensitive, no space) appended to it.  This will also be interpreted in seconds.
 - The user may specify a decimal integer value with "ms" (case-insensitive, no space) appended to it.  This will be interpreted by the OCSP or URICertStore subsystems as milliseconds.  For example, a value of "2500ms" will be a 2.5 second timeout.
 - As with the current behavior, non-numeric, non-decimal (e.g. hexadecimal values prepended by "0x", etc) values will be interpreted as illegal and will default to the 15 second timeout.  The same is true for negative values.
 - Whether the value is interpreted in seconds or milliseconds, a value of zero will disable the timeout.
 - For the newly proposed certificate fetching properties, the `com.sun.security.enableAIAcaIssuers` property must be set to true in order for fetching to occur and these property timeouts to be enabled.

Specification
-------------
There are no specification changes since the classes that act upon these properties are not exported through the java.base module.


Comments
Moving to Approved.
23-05-2023

In response to PR comments by [~mullan] I've added a new `com.sun.security.ocsp.readtimeout` alongside the existing ocsp timeout property so they conform to the CRL and cert fetching timeout property pairs. In practice this will have no effect in the default case, since right now the 15 second default is applied to both OCSP connect and read timeouts though the one system property. In the new scheme the defaults will still be the same value, but now users can tailor the connect and read timeouts for OCSP independently.
19-05-2023

Added one minor change based on review comments: a numeric value ending in "s" will be interpreted as seconds as well as a simple number. So values of "10" and "10s" will be equivalent.
03-05-2023

I don't think there is, to be honest. We were looking for a way to not impact the existing behavior but allow the finer granularity without using new properties. This seemed like a fair way to approach it since folks who didn't need inter-second granularity didn't have to modify anything. I think often times these timeout properties just use milliseconds to begin with so they don't have to extend the syntax at all.
02-05-2023

Hmmm. Generally sounds fine; are there any precedents you know of for similar seconds/milliseconds handling for other timeout-based properties in the JDK? Moving to Provisional.
02-05-2023