Skip to content

Fix CA certificate extraction from PKCS12 key entry chains in SecureSockets#3779

Merged
kasemir merged 1 commit intoControlSystemStudio:masterfrom
george-mcintyre:fix/pva-ca-cert-extraction
Apr 15, 2026
Merged

Fix CA certificate extraction from PKCS12 key entry chains in SecureSockets#3779
kasemir merged 1 commit intoControlSystemStudio:masterfrom
george-mcintyre:fix/pva-ca-cert-extraction

Conversation

@george-mcintyre
Copy link
Copy Markdown
Contributor

Problem

Java's TrustManagerFactory only trusts entries with alias type trustedCertEntry. CA certificates embedded in the certificate chain of a PrivateKeyEntry are not automatically trusted — unless Oracle's proprietary OID (1.2.840.113556.1.8000.2554.43570) is present in the keystore metadata. PVXS-created .p12 files do not include this OID, so the TrustManager cannot verify server certificates and TLS connections fail.

Fix

After loading the PKCS12 keystore, iterate over every PrivateKeyEntry and walk its certificate chain. Any X509Certificate that is its own issuer (i.e. a self-signed CA root) or any intermediate CA is re-added to the keystore as a dedicated trustedCertEntry. This matches the behaviour of PVXS's extractCAs() function and ensures interoperability with PVXS-generated keystores.

Files Changed

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

@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 kasemir merged commit 0e08779 into ControlSystemStudio:master Apr 15, 2026
3 of 4 checks passed
@george-mcintyre george-mcintyre deleted the fix/pva-ca-cert-extraction branch April 16, 2026 00:12
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