Skip to content

Infer UI, DRPC and logviewer HTTPS store types from the file extension - #9287

Open
dragonknightk wants to merge 2 commits into
apache:masterfrom
dragonknightk:infer-keystore-type-from-path
Open

dragonknightk wants to merge 2 commits into
apache:masterfrom
dragonknightk:infer-keystore-type-from-path

Conversation

@dragonknightk

@dragonknightk dragonknightk commented Nov 18, 2026 •

Copy link
Copy Markdown

Fixes #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.

(。•̀ᴗ-)✧

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
rzo1 requested review from GGraziadei and reiabreu November 18, 2026 08:50
@rzo1 rzo1 added this to the 3.3.0 milestone Nov 18, 2026

@rzo1 rzo1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread docs/SECURITY.md Outdated

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
@dragonknightk

Copy link
Copy Markdown
Author

@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. (。•̀ᴗ-)✧

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[STORM-3960] Read keystore/truststore files in jks or pkcs12 prompt based on extension

2 participants