Skip to content

Commit 80d938f

Browse files
committed
For OpenSSL+FFM, only configure CA certs if configuration is present
1 parent 4adf369 commit 80d938f

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,7 @@ public void init(KeyManager[] kms, TrustManager[] tms, SecureRandom sr) throws K
557557
SSL_CTX_set_verify(state.sslCtx, value,
558558
SSL_CTX_set_verify$callback.allocate(new OpenSSLEngine.VerifyCallback(), contextArena));
559559

560-
// Trust and certificate verification
560+
// Trust and certificate verification (optional - may not be configured)
561561
if (tms != null) {
562562
// Client certificate verification based on custom trust managers
563563
x509TrustManager = chooseTrustManager(tms);
@@ -580,7 +580,7 @@ public void init(KeyManager[] kms, TrustManager[] tms, SecureRandom sr) throws K
580580
log.debug(sm.getString("openssl.addedClientCaCert", caCert.toString()));
581581
}
582582
}
583-
} else {
583+
} else if (sslHostConfig.getCaCertificateFile() != null || sslHostConfig.getCaCertificatePath() != null) {
584584
// Client certificate verification based on trusted CA files and dirs
585585
MemorySegment caCertificateFileNative = sslHostConfig.getCaCertificateFile() != null ?
586586
localArena
@@ -590,9 +590,7 @@ public void init(KeyManager[] kms, TrustManager[] tms, SecureRandom sr) throws K
590590
localArena
591591
.allocateFrom(SSLHostConfig.adjustRelativePath(sslHostConfig.getCaCertificatePath())) :
592592
MemorySegment.NULL;
593-
if ((sslHostConfig.getCaCertificateFile() != null || sslHostConfig.getCaCertificatePath() != null) &&
594-
SSL_CTX_load_verify_locations(state.sslCtx, caCertificateFileNative,
595-
caCertificatePathNative) <= 0) {
593+
if (SSL_CTX_load_verify_locations(state.sslCtx, caCertificateFileNative, caCertificatePathNative) <= 0) {
596594
logLastError("openssl.errorConfiguringLocations");
597595
} else {
598596
var caCerts = SSL_CTX_get_client_CA_list(state.sslCtx);

webapps/docs/changelog.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,11 @@
241241
Better warning message when <code>OpenSSLConf</code> configuration
242242
elements are used with a JSSE TLS implementation. (markt)
243243
</fix>
244+
<fix>
245+
When using OpenSSL via FFM, don't log a warning about missing CA
246+
certificates unless CA certificates were configured and the
247+
configuration failed. (markt)
248+
</fix>
244249
</changelog>
245250
</subsection>
246251
<subsection name="Jasper">

0 commit comments

Comments
 (0)