Repository navigation
KNOX-3519 - Set the JWKS host on the TLS socket so HTTPS endpoint identification works under BC-FIPS - #1459
KNOX-3519 - Set the JWKS host on the TLS socket so HTTPS endpoint identification works under BC-FIPS#1459moresandeep wants to merge 1 commit into
Conversation
Test Results 4 files 4 suites 1m 29s ⏱️ Results for commit bef5a3e. |
lmccay
left a comment
There was a problem hiding this comment.
Made some comments and asked questions.
| * deployments. On sockets that do not expose the method this decorator is a no-op, which is | ||
| * correct for the stock JSSE: it identifies IP endpoints from the URL already. | ||
| */ | ||
| class SetHostSSLSocketFactory extends SSLSocketFactory { |
There was a problem hiding this comment.
minor nit - I don't like that this classname reads like a verb rather than a noun.
Not a blocker though. Maybe HostSettingSSLSocketFactory is a better noun based name?
| /* Not reachable through this type; a public interface may still expose it. */ | ||
| continue; | ||
| } catch (InvocationTargetException | RuntimeException e) { | ||
| return false; |
There was a problem hiding this comment.
Should a single failure to set it even though it appears to have such a method fail the entire iteration over the types? Should we not continue to walk the hierarchy to see if one will work? Are we assuming that someone overrode another implementation in order to purposely not support it and throw a RTE rather than just no-op it?
| * @return {@code true} when the host was applied, {@code false} when the socket does not | ||
| * support it or the call failed | ||
| */ | ||
| static boolean setHost(Socket socket, String host) { |
There was a problem hiding this comment.
It seems that we are iterating over the class hierarchy of the socket looking for the first one that accepts or rejects a setHost method call. IIUC, then this looks for the most specific implementation of setHost that is public. If it fails due to method visibility it continues to walk the hierarchy to try and find a public one that will work. If that's accurate then I think we should document this a bit here to describe the intent at least.
KNOX-3519 - Set the JWKS host on the TLS socket so HTTPS endpoint identification works under BC-FIPS
What changes were proposed in this pull request?
Under the BouncyCastle FIPS JSSE provider, fetching a JWKS over HTTPS fails before any
certificate is examined:
JWT verification then fails and the request is rejected with 401, even when the JWKS
endpoint's certificate is fully trusted and carries a matching SAN.
The change. A new
SetHostSSLSocketFactorydecorator stamps the JWKS URL's host ontoevery socket it creates, via
setHost(String)as declared byorg.bouncycastle.jsse.BCSSLSocket. It is wired in at both JWKS retrieval paths:DefaultTokenAuthorityService.buildJwkSource(default truststore) andIssuerTrustResourceRetriever(per-issuer CA bundle).Notes on the implementation:
TLS provider, it is present only in FIPS deployments. Lookup walks interfaces first,
because BC's socket implementations are package-private and the method is only invocable
through the public
BCSSLSocketinterface.setHostthe decorator is a no-op. That is correct for thestock JSSE, which identifies HTTPS endpoints from the URL already, so non-FIPS deployments
are unaffected.
carry a SAN matching the JWKS host.
(connect/read 500 ms, 51200 byte limit,
disconnectAfterUse = true), so timeout and sizebehaviour are unchanged.
How was this patch tested?
Patch was tested locally.