Skip to content

Add EPICS_PVA_TLS_KEYCHAIN_PWD_FILE for file-based keychain password#3783

Open
george-mcintyre wants to merge 2 commits intoControlSystemStudio:masterfrom
george-mcintyre:feat/pva-keychain-pwd-file
Open

Add EPICS_PVA_TLS_KEYCHAIN_PWD_FILE for file-based keychain password#3783
george-mcintyre wants to merge 2 commits intoControlSystemStudio:masterfrom
george-mcintyre:feat/pva-keychain-pwd-file

Conversation

@george-mcintyre
Copy link
Copy Markdown
Contributor

Motivation

The existing EPICS_PVA_TLS_KEYCHAIN setting embeds the keystore password directly in the path string (e.g. path/to/client.p12|password). This is convenient for development but unsuitable for production environments where secrets must not appear in environment variables, process listings, or configuration files.

Container orchestration platforms such as Kubernetes mount secrets as files (e.g. via Secret volumes or external secret operators like Vault Agent). There was no way to supply the keychain password via a file path.

Change

Two new environment variables are introduced:

Variable Purpose
EPICS_PVA_TLS_KEYCHAIN_PWD_FILE Path to a file containing the client keychain password
EPICS_PVAS_TLS_KEYCHAIN_PWD_FILE Path to a file containing the server keychain password

When set, SecureSockets reads the password from the referenced file instead of parsing it from the keychain path string. The inline path|password syntax continues to work; the _PWD_FILE variable takes precedence when both are present.

This enables secure password injection for Kubernetes deployments using secretKeyRef volume mounts without patching the keychain path.

Files Changed

  • core/pva/src/main/java/org/epics/pva/common/SecureSockets.java

Copy link
Copy Markdown
Collaborator

@kasemir kasemir left a comment

Choose a reason for hiding this comment

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

Like all PVA settings, the new EPICS_PVAS_TLS_KEYCHAIN_PWD_FILE and EPICS_PVA_TLS_KEYCHAIN_PWD_FILE should be defined and documented in src/main/java/org/epics/pva/PVASettings.java, next to the existing definition and documentation of PVASettings.EPICS_PVAS_TLS_KEYCHAIN and PVASettings.EPICS_PVA_TLS_KEYCHAIN

Per review feedback: all PVA settings must be declared as public static
fields in PVASettings.java, documented next to their related keychain
settings, and initialised in the static block.

- Add EPICS_PVAS_TLS_KEYCHAIN_PWD_FILE next to EPICS_PVAS_TLS_KEYCHAIN
- Add EPICS_PVA_TLS_KEYCHAIN_PWD_FILE next to EPICS_PVA_TLS_KEYCHAIN
- Initialise both in the static block alongside their keychain peers
- Update SecureSockets.readKeychainPassword() to read from the
  PVASettings fields rather than calling PVASettings.get() directly
Copy link
Copy Markdown
Contributor Author

@george-mcintyre george-mcintyre left a comment

Choose a reason for hiding this comment

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

Done in cd72fb5. Both EPICS_PVAS_TLS_KEYCHAIN_PWD_FILE and EPICS_PVA_TLS_KEYCHAIN_PWD_FILE are now declared as public static String fields in PVASettings, documented in the same style as EPICS_PVAS_TLS_KEYCHAIN / EPICS_PVA_TLS_KEYCHAIN immediately adjacent to them, and initialised in the static block right after their respective keychain peers. SecureSockets.readKeychainPassword() now reads from the PVASettings fields directly instead of calling PVASettings.get() ad hoc.

@sonarqubecloud
Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
B Maintainability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@kasemir
Copy link
Copy Markdown
Collaborator

kasemir commented Apr 15, 2026

Looks good, except there's now a minor merge conflict

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants