Repository navigation
Infer UI, DRPC and logviewer HTTPS store types from the file extension - #9287
dragonknightk wants to merge 2 commits into
Conversation
Closes issue 7742 ## What is the purpose of the change When `*.https.keystore.type` or `*.https.truststore.type` is not set, the UI, DRPC and logviewer HTTPS connectors now infer the type from the file extension, the same way `ThriftClient` and `ReloadableX509KeyManager` already do. - Configurations that set a type keep their behavior. - `.jks` is read as JKS, and `.p12`, `.pkcs12` or `.pfx` is read as PKCS12. - A keystore with any other extension falls back to JKS. - A truststore with any other extension and no type is still not used. With `drpc.https.keystore.type: "JKS"` in `defaults.yaml`, a DRPC type always counts as configured, so the entry is removed. The JKS fallback keeps the old DRPC result for files that have no known extension. The change is in `UIHelpers.mkSslConnector`, the one place the three daemons build their HTTPS connector. `ReloadableX509TrustManager` is not changed, because with the JDK default `keystore.type.compat=true` its default-type `KeyStore` already loads both JKS and PKCS12 files. ## How was the change tested New `UIHelpersTest` cases use keystores generated at test time with `keytool`: - With no types set, a `.p12` keystore is read as PKCS12 and a `.jks` truststore as JKS, and the SSL context starts with both files. - With no type set, a keystore with an unknown extension is read as JKS. - With no type set, a truststore with an unknown extension is not used. - Explicit types win over the extension. The first two cases fail without the change in `UIHelpers`, because the store type stays null. ## Upgrade notes - UI and logviewer HTTPS with no keystore type set used to fail at startup. They now start, using the inferred type or JKS. - A truststore with a path and password but no type used to be ignored, so Jetty validated client certificates against the keystore entries. It is now used when its extension is `.jks`, `.p12`, `.pkcs12` or `.pfx`. Deployments with client auth enabled then validate client certificates against the truststore and can reject clients that only the keystore trusted. - DRPC with no keystore type set now reads a `.p12`, `.pkcs12` or `.pfx` keystore as PKCS12 instead of JKS. With the JDK default `keystore.type.compat=true` this has no visible effect, because both types load both formats. ## AI Disclosure Human-led contribution. Grok Bot, working for dragonknightk, assisted with this change, including the code, tests, and description. All submitted content was reviewed by a human before submission. Signed-off-by: dragonknightk <37928252+dragonknightk@users.noreply.github.com>
rzo1
left a comment
There was a problem hiding this comment.
Thx for the contrib. The new tests cover the fix. Reusing SecurityUtils.inferKeyStoreTypeFromPath keeps the HTTPS connectors consistent with the Thrift side, and the upgrade notes are clear. Requesting one change about the truststore, see inline. The docs note is optional.
| factory.setKeyManagerPassword(keyPassword); | ||
|
|
||
| if (tsPath != null && tsPassword != null && tsType != null) { | ||
| if (tsPath != null && tsPassword != null && trustStoreType != null) { |
There was a problem hiding this comment.
A truststore with a path and password set but an unknown extension (e.g. truststore.dat) and no type is still silently skipped. With client auth enabled, Jetty then checks client certificates against the keystore instead, and nothing in the logs says so. Could you at least log a WARN here when tsPath is set but no type could be determined? Alternatively, fall back to JKS like the keystore does: with keystore.type.compat=true that loads both formats anyway. Either way it would be better than ignoring the setting silently.
|
|
||
| UI,DRPC and LOGVIEWER allows users to configure ssl . | ||
|
|
||
| The `*.https.keystore.type` and `*.https.truststore.type` configs are optional. A configured type is always used. When a type is not set, it is inferred from the file extension: `.jks` is read as JKS, and `.p12`, `.pkcs12` or `.pfx` is read as PKCS12. A keystore with any other extension is read as JKS. A truststore with any other extension is not used unless its type is set. |
There was a problem hiding this comment.
nit: the root SECURITY.md also lists ui.https.keystore.type and drpc.https.keystore.type with "(example "jks")". Worth adding the same sentence there, or pointing it to this section, so the two docs don't drift apart.
Closes issue 7742 ## What is the purpose of the change When `*.https.keystore.type` or `*.https.truststore.type` is not set, the UI, DRPC and logviewer HTTPS connectors now infer the type from the file extension, the same way `ThriftClient` and `ReloadableX509KeyManager` already do. - Configurations that set a type keep their behavior. - `.jks` is read as JKS, and `.p12`, `.pkcs12` or `.pfx` is read as PKCS12. - A keystore or truststore with any other extension falls back to JKS, as in the Thrift TLS transport. With `drpc.https.keystore.type: "JKS"` in `defaults.yaml`, a DRPC type always counts as configured, so the entry is removed. The JKS fallback keeps the old DRPC result for files that have no known extension. The change is in `UIHelpers.mkSslConnector`, the one place the three daemons build their HTTPS connector. `ReloadableX509TrustManager` is not changed, because with the JDK default `keystore.type.compat=true` its default-type `KeyStore` already loads both JKS and PKCS12 files. ## How was the change tested New `UIHelpersTest` cases use keystores generated at test time with `keytool`: - With no types set, a `.p12` keystore is read as PKCS12 and a `.jks` truststore as JKS, and the SSL context starts with both files. - With no type set, a keystore with an unknown extension is read as JKS. - With no type set, a truststore with an unknown extension is read as JKS, and the SSL context loads it even though the file holds PKCS12. - Explicit types win over the extension. The first three cases fail without the change in `UIHelpers`: the keystore type stays null and the truststore is not used. ## Upgrade notes - UI and logviewer HTTPS with no keystore type set used to fail at startup. They now start, using the inferred type or JKS. - A truststore with a path and password but no type used to be ignored, so Jetty validated client certificates against the keystore entries. It is now used, with the type inferred from its extension or JKS otherwise. Deployments with client auth enabled then validate client certificates against the truststore and can reject clients that only the keystore trusted. - DRPC with no keystore type set now reads a `.p12`, `.pkcs12` or `.pfx` keystore as PKCS12 instead of JKS. With the JDK default `keystore.type.compat=true` this has no visible effect, because both types load both formats. ## AI Disclosure Human-led contribution. Grok Bot, working for dragonknightk, assisted with this change, including the code, tests, and description. All submitted content was reviewed by a human before submission. Signed-off-by: dragonknightk <37928252+dragonknightk@users.noreply.github.com>
|
@rzo1 Thanks for the review! Both points are addressed: the truststore now falls back to JKS like the keystore, and the root SECURITY.md points to the docs section instead of repeating the rules. (。•̀ᴗ-)✧ |
Fixes #7742
What is the purpose of the change
When
*.https.keystore.typeor*.https.truststore.typeis not set, the UI, DRPC and logviewer HTTPS connectors now infer the type from the file extension, the same wayThriftClientandReloadableX509KeyManageralready do..jksis read as JKS, and.p12,.pkcs12or.pfxis read as PKCS12.With
drpc.https.keystore.type: "JKS"indefaults.yaml, a DRPC type always counts as configured, so the entry is removed. The JKS fallback keeps the old DRPC result for files that have no known extension.The change is in
UIHelpers.mkSslConnector, the one place the three daemons build their HTTPS connector.ReloadableX509TrustManageris not changed, because with the JDK defaultkeystore.type.compat=trueits default-typeKeyStorealready loads both JKS and PKCS12 files.How was the change tested
New
UIHelpersTestcases use keystores generated at test time withkeytool:.p12keystore is read as PKCS12 and a.jkstruststore as JKS, and the SSL context starts with both files.The first three cases fail without the change in
UIHelpers: the keystore type stays null and the truststore is not used.Upgrade notes
.p12,.pkcs12or.pfxkeystore as PKCS12 instead of JKS. With the JDK defaultkeystore.type.compat=truethis has no visible effect, because both types load both formats.AI Disclosure
Human-led contribution. Grok Bot, working for dragonknightk, assisted with this change, including the code, tests, and description. All submitted content was reviewed by a human before submission.
(。•̀ᴗ-)✧