Honor key-store, trust-store and classname of the ssl element - #26153
Honor key-store, trust-store and classname of the ssl element#26153renatsaf wants to merge 3 commits into
Conversation
|
A test is failing: |
The GlassFishSSLContextFactory read the keystore and keystoreType attributes only to log them and always built the key managers and the trust store from SSLUtils, which is a singleton opening a single pair of stores from the javax.net.ssl.keyStore and javax.net.ssl.trustStore system properties. The key-store, trust-store, their types and their passwords configured in the ssl element of a protocol were therefore silently ignored, although the admin console and the config model offer them. A listener which configures its own store is now served by the generic SSLContextFactory, which loads the store from the configured path with the configured password. Listeners without their own store keep using the server stores managed with the domain master password. Fixes eclipse-ee4j#18175 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Since the SSLImplementation became a HK2 contract, SSLConfigurator resolved it from the service locator and used the classname attribute only as a fallback for the case when no service was registered. As GlassfishSSLImpl is a service and the only implementation on the server classpath, the attribute was never used and a custom SSLImplementation configured in the domain.xml was silently ignored. The attribute is honored again; the registered service is used when the attribute is not set or when it names that service. The class is now loaded by Utils.loadClass, so the thread context class loader is tried first. Refs eclipse-ee4j#18175 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The test concatenated the absolute path of the docroot with the absolute path of the keystore file, so the key-store of the listener was a path which cannot exist. It went unnoticed because the attribute was ignored and the server keystore taken from the javax.net.ssl.keyStore system property was used instead. Now that the key-store of the ssl element is honored, the listener fails to load its keystore and the client sees a terminated handshake. The listener is configured with the keystore of the test, which is also the server keystore, as it is in a default domain. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
c8ac1be to
696ebb6
Compare
|
Thanks, that failure was real and it pointed at two things. The test itself is broken: That path has never existed. It went unnoticed because the It is worth saying out loud, because it is the one upgrade visible effect of this PR: a listener I also replaced the way the decision is made. Comparing the resolved store path with the path of the Rebased on current main (the |
Fixes #18175
Problem
key-storeandtrust-storeconfigured in thesslelement of a protocol have never had any effect:GlassFishSSLContextFactoryread thekeystoreandkeystoreTypeattributes only to log them andthen built the key managers, as well as the trust store, from
SSLUtils.SSLUtilsdelegates to theSecuritySupportsingleton, which opens a single pair of stores in its@PostConstructfrom thejavax.net.ssl.keyStore/javax.net.ssl.trustStoresystem properties and the domain masterpassword. The store location, type and password of a listener were therefore silently ignored, while
the admin console offers them as editable fields and the config model and
asadmin setaccept them.While fixing that I found a second, newer defect. Since
SSLImplementationbecame a HK2 contract,SSLConfigurator.getSslImplementation()resolves it from the service locator unconditionally anduses the
classnameattribute only when no service is registered.GlassfishSSLImplis a serviceand the only implementation on the server classpath, so the attribute is never used. That silently
disables the pluggability documented in
http_https.adocand it also removed the workaround forthis very issue that was suggested in 2012 (clearing
classnameso that the generic Grizzlyimplementation, which does honor the stores, is used).
Solution
Per listener stores. A listener which configures its own store is served by the generic
SSLContextFactory, which loads the store from the configured path, with the configured type andpassword. Listeners without their own store keep using the server stores managed by
SSLUtils, sothe stores protected by the master password stay the default and nothing changes for a default
domain. The keystore and the truststore are decided independently, so overriding only one of them
works. The store paths themselves cannot carry that decision, because
SSLConfiguratormerges themwith the system properties of the server before the factory sees them; it therefore marks the stores
which come from the
sslelement with the newkeystoreConfiguredandtruststoreConfiguredattributes, and the factory reads that mark.
The classname attribute. It is honored again. The implementation registered in the service
locator is used when the attribute is not set or when it names exactly that implementation, which is
the case of every default domain, so this is not a behaviour change for stock configurations. The
class is loaded by
Utils.loadClass, which tries the thread context class loader first.Tests
GlassFishSSLContextFactoryTest(new; the module had no test sources yet) creates a keystore and atruststore with
KeyTooland configures them as the stores of the listener. The factory is createdwith an intentionally empty
ServiceLocator, so any fall back to the server stores fails. One of thetests asks for the
s1asalias, which exists only in a server keystore, and asserts that theresulting
IOExceptionnames it - that proves the keystore of the listener is really the one whichis opened.
GrizzlyConfigTest.sslWithConfiguredImplementationserves HTTPS from a configuration whosesslelement names
ConfiguredSSLImplementation, a test implementation which is intentionally not a HK2service and counts its usages.
Both reproducers were verified to fail without the fixes.
EmbeddedAddHttpsListenerTestconcatenated the absolute path of the docroot with the absolute pathof the keystore file, so its listener was configured with a
key-storewhich cannot exist. It wentunnoticed because the attribute was ignored; now the listener really tries to open that path and the
client sees a terminated handshake. The listener is configured with the keystore of the test, which
is also the server keystore, as it is in a default domain - the test now covers the configured store
path end to end.
Not included
key-store-passwordstill falls back tojavax.net.ssl.keyStorePasswordand then to the default password, which is the existing behaviourof
SSLConfigurator. Falling back to the master password instead may be more useful, but it wouldmean reaching the security services from
grizzly-config, so I left it for a follow up if youconsider it right.
create-sslstill has no parameters for the stores and the documentation describes only theclassnameattribute. Happy to add both once the approach here is agreed.🤖 Generated with Claude Code