hanicz opened a new pull request, #1542:
URL: https://github.com/apache/knox/pull/1542

   …ns in FIPS mode
   
   [KNOX-3614](https://issues.apache.org/jira/browse/KNOX-3614) - Use the 
gateway HTTP client truststore for LDAPS connections in FIPS mode
   
   ## What changes were proposed in this pull request?
   
   On FIPS deployments, the JVM's default truststore might be disabled with 
`-Djavax.net.ssl.trustStore=NONE`, so BouncyCastle FIPS doesn't try to load the 
JDK's `cacerts`. Most of Knox's outbound TLS clients already use the configured 
HTTP client truststore. The Shiro LDAP realm doesn't: it goes through JNDI, 
which falls back to the JVM default truststore, so with that setting `ldaps://` 
binds fail.
   
   This PR makes LDAPS use the gateway HTTP client truststore in FIPS mode:
   
   - `KnoxLdapContextFactory` sets `java.naming.ldap.factory.socket` to the new 
`KnoxLdapSslSocketFactory` when all of these hold:
     - FIPS is enabled (`FipsUtils.isFipsEnabledWithBCProvider()`).
     - Every provider URL is `ldaps://`, or `java.naming.security.protocol=ssl`.
     - No socket factory is configured explicitly.
   - `KnoxLdapSslSocketFactory` uses an SSLContext built once from 
`KeystoreService.getTruststoreForHttpClient()` 
(`gateway.httpclient.truststore.*`).
   - When no HTTP client truststore is configured, or it can't be loaded, 
behaviour is unchanged and LDAPS keeps using the JVM default truststore. This 
is logged once.
   - Non-FIPS deployments, plain `ldap://` and mixed `ldap://`/`ldaps://` URL 
lists are not affected.
   
   ## How was this patch tested?
   
   - New unit tests in `KnoxLdapContextFactoryTest` cover:
     - FIPS with `ldaps://` and a truststore.
     - The truststore being loaded only once.
     - Fallback when no truststore is configured.
     - Non-FIPS, plain `ldap://`, mixed URLs, and an explicit socket factory.
     - URL detection.
   - Manual check on JDK 17 with `-Djavax.net.ssl.trustStore=NONE`, against a 
local TLS server, with and without a connect timeout:
     - Without the fix the JNDI `ldaps://` handshake fails.
     - With the fix it succeeds through `KnoxLdapSslSocketFactory`.
   
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to