Skip to content

Migrate legacy JKS/JCEKS security stores to PKCS12 when upgrading from 7.0.x#26109

Open
renatsaf wants to merge 1 commit into
eclipse-ee4j:mainfrom
renatsaf:issue-26107-pkcs12-store-migration
Open

Migrate legacy JKS/JCEKS security stores to PKCS12 when upgrading from 7.0.x#26109
renatsaf wants to merge 1 commit into
eclipse-ee4j:mainfrom
renatsaf:issue-26107-pkcs12-store-migration

Conversation

@renatsaf

Copy link
Copy Markdown
Contributor

Problem

Commit 096ace25 ("Switching from JKS and JCEKS to PKCS12") changed GlassFish 7.1.0+ to read and write its security stores exclusively in PKCS12 under fixed file names (keystore.p12, cacerts.p12, domain-passwords.p12). A domain created by 7.0.x or older instead contains keystore.jks, cacerts.jks and a JCEKS domain-passwords. SecurityUpgradeService upgraded the JACC provider, the JDBC-realm digest, generated policy files and warned on NSS — but never converted the keystores, so an upgraded domain could fail to read its stores. Follow-up requested in PR #26103.

Change

Extend SecurityUpgradeService.postConstruct() with a migrateLegacyKeystores() step that detects the legacy stores in <domain>/config and converts them to PKCS12 under the new names using the domain master password:

  • keystore.jkskeystore.p12
  • cacerts.jkscacerts.p12
  • domain-passwords (JCEKS) → domain-passwords.p12

Properties:

  • Idempotent — a store is skipped if the legacy file is absent or the .p12 target already exists.
  • Non-destructive — each migrated legacy file is retained as <name>.bak.
  • Graceful — if the master password is unavailable, or a conversion fails, it logs a warning (new NCLS-SECURITY-01016/01017/01018 messages), removes any half-written .p12, and never aborts the upgrade.
  • Conversion uses java.security.KeyStore directly (no external keytool process) and copies private keys, trusted certificates and secret keys.

Runs on the start-domain --upgrade path. NSS (.db) stores remain out of scope (existing warning unchanged). Coordinates with the cluster sync-list fix in #26103 so migrated instances receive the .p12 files.

Testing

Added SecurityUpgradeServiceTest covering the secret-key JCEKS domain-passwords case (entries and store type preserved). Module compiles and tests pass locally.

Fixes #26107

🤖 Generated with Claude Code

GlassFish 7.1.0+ reads its security stores exclusively as PKCS12 under
fixed file names (keystore.p12, cacerts.p12, domain-passwords.p12), but a
domain created by 7.0.x or older still contains keystore.jks, cacerts.jks
and a JCEKS domain-passwords. SecurityUpgradeService did not convert them,
so an upgraded domain could fail to read its stores.

Extend SecurityUpgradeService.postConstruct() to detect the legacy stores
in <domain>/config and convert them to PKCS12 using the domain master
password. The conversion is idempotent (skips when the legacy file is
absent or the .p12 target already exists), retains each legacy file as
<name>.bak, and fails gracefully without aborting the upgrade.

Adds a unit test covering the secret-key JCEKS domain-passwords case.

Fixes eclipse-ee4j#26107

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.

SecurityUpgradeService should migrate keystore/cacerts/domain-passwords to PKCS12 when upgrading from 7.0.x or older

1 participant