[
https://issues.apache.org/jira/browse/KNOX-3614?focusedWorklogId=1056873&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-1056873
]
ASF GitHub Bot logged work on KNOX-3614:
----------------------------------------
Author: ASF GitHub Bot
Created on: 24/Nov/26 14:46
Start Date: 24/Nov/26 14:46
Worklog Time Spent: 10m
Work Description: 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`.
Issue Time Tracking
-------------------
Worklog Id: (was: 1056873)
Remaining Estimate: 0h
Time Spent: 10m
> Use the gateway HTTP client truststore for LDAPS connections in FIPS mode
> -------------------------------------------------------------------------
>
> Key: KNOX-3614
> URL: https://issues.apache.org/jira/browse/KNOX-3614
> Project: Apache Knox
> Issue Type: Task
> Components: LDAP
> Affects Versions: 3.0.0
> Reporter: Tamás Hanicz
> Assignee: Tamás Hanicz
> Priority: Major
> Time Spent: 10m
> Remaining Estimate: 0h
>
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)