Skip to content

Commit ddbdd91

Browse files
committed
Add verify flags to SSLHostConfig
1 parent 28a65b2 commit ddbdd91

File tree

6 files changed

+31
-3
lines changed

6 files changed

+31
-3
lines changed

java/org/apache/tomcat/util/net/SSLHostConfig.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ public class SSLHostConfig implements Serializable {
120120
private boolean ocspEnabled = false;
121121
private boolean ocspSoftFail = true;
122122
private int ocspTimeout = 15000;
123+
private int ocspVerifyFlags = 0;
123124
private final Set<String> protocols = new HashSet<>();
124125
// Values <0 mean use the implementation default
125126
private int sessionCacheSize = -1;
@@ -594,6 +595,16 @@ public void setOcspTimeout(int ocspTimeout) {
594595
}
595596

596597

598+
public int getOcspVerifyFlags() {
599+
return ocspVerifyFlags;
600+
}
601+
602+
603+
public void setOcspVerifyFlags(int ocspVerifyFlags) {
604+
this.ocspVerifyFlags = ocspVerifyFlags;
605+
}
606+
607+
597608
public void setProtocols(String input) {
598609
protocols.clear();
599610
explicitlyRequestedProtocols.clear();

java/org/apache/tomcat/util/net/openssl/OpenSSLConfCmd.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public class OpenSSLConfCmd implements Serializable {
2525
public static final String NO_OCSP_CHECK = "NO_OCSP_CHECK";
2626
public static final String OCSP_SOFT_FAIL = "OCSP_SOFT_FAIL";
2727
public static final String OCSP_TIMEOUT = "OCSP_TIMEOUT";
28+
public static final String OCSP_VERIFY_FLAGS = "OCSP_VERIFY_FLAGS";
2829

2930
@Serial
3031
private static final long serialVersionUID = 1L;

java/org/apache/tomcat/util/net/openssl/OpenSSLContext.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,8 @@ public void init(KeyManager[] kms, TrustManager[] tms, SecureRandom sr) throws K
371371
Boolean.toString(sslHostConfig.getOcspSoftFail())));
372372
sslHostConfig.getOpenSslConf().addCmd(new OpenSSLConfCmd(OpenSSLConfCmd.OCSP_TIMEOUT,
373373
Integer.toString(sslHostConfig.getOcspTimeout())));
374+
sslHostConfig.getOpenSslConf().addCmd(new OpenSSLConfCmd(OpenSSLConfCmd.OCSP_VERIFY_FLAGS,
375+
Integer.toString(sslHostConfig.getOcspVerifyFlags())));
374376
}
375377

376378
if (negotiableProtocols != null && !negotiableProtocols.isEmpty()) {

java/org/apache/tomcat/util/net/openssl/panama/OpenSSLContext.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ private boolean checkConf(OpenSSLConf conf) {
363363
ok = true;
364364
} else if (name.equals(OpenSSLConfCmd.OCSP_TIMEOUT)) {
365365
ok = true;
366-
} else if (name.equals("OCSP_VERIFY_FLAGS")) {
366+
} else if (name.equals(OpenSSLConfCmd.OCSP_VERIFY_FLAGS)) {
367367
ok = true;
368368
} else {
369369
int code = SSL_CONF_cmd_value_type(state.confCtx, localArena.allocateFrom(name));
@@ -441,8 +441,8 @@ private boolean applyConf(OpenSSLConf conf) {
441441
} else if (name.equals(OpenSSLConfCmd.OCSP_TIMEOUT)) {
442442
// Ignore - Tomcat internal - set directly
443443
rc = 1;
444-
} else if (name.equals("OCSP_VERIFY_FLAGS")) {
445-
ocspVerifyFlags = Integer.parseInt(value);
444+
} else if (name.equals(OpenSSLConfCmd.OCSP_VERIFY_FLAGS)) {
445+
// Ignore - Tomcat internal - set directly
446446
rc = 1;
447447
} else {
448448
rc = SSL_CONF_cmd(state.confCtx, localArena.allocateFrom(name), localArena.allocateFrom(value));
@@ -573,6 +573,7 @@ public void init(KeyManager[] kms, TrustManager[] tms, SecureRandom sr) throws K
573573
}
574574
ocspSoftFail = sslHostConfig.getOcspSoftFail();
575575
ocspTimeout = sslHostConfig.getOcspTimeout();
576+
ocspVerifyFlags = sslHostConfig.getOcspVerifyFlags();
576577

577578
// Set int verify_callback(int preverify_ok, X509_STORE_CTX *x509_ctx) callback
578579
SSL_CTX_set_verify(state.sslCtx, value,

webapps/docs/changelog.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,11 @@
289289
Add support for soft failure of OCSP checks with soft failure support
290290
disabled by default. (markt)
291291
</add>
292+
<add>
293+
Add support for configuring the verification flags passed to
294+
<code>OCSP_basic_verify</code> when using an OpenSSL based TLS
295+
implementation. (markt)
296+
</add>
292297
</changelog>
293298
</subsection>
294299
<subsection name="Jasper">

webapps/docs/config/http.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1372,6 +1372,14 @@
13721372
used.</p>
13731373
</attribute>
13741374

1375+
<attribute name="ocspVerify" required="false">
1376+
<p>Configures the verification flags passed to
1377+
<code>OCSP_basic_verify</code> when using OCSP checks with an OpenSSL
1378+
based TLS implementation. This attribute has no effect if a JSSE based TLS
1379+
implementation is used.</p>
1380+
<p>If not specified, the default value of <code>0</code> will be used.</p>
1381+
</attribute>
1382+
13751383
<attribute name="protocols" required="false">
13761384
<p>The names of the protocols to support when communicating with clients.
13771385
This should be a list of any combination of the following:

0 commit comments

Comments
 (0)