Skip to content

[backport camel-4.22.x] CAMEL-22114: Fix PQC KeyStore tests on Java 25 (InvalidKeyException) - #25753

Merged
davsclaus merged 1 commit into
camel-4.22.xfrom
backport/25510-to-camel-4.22.x
Aug 26, 2026
Merged

[backport camel-4.22.x] CAMEL-22114: Fix PQC KeyStore tests on Java 25 (InvalidKeyException)#25753
davsclaus merged 1 commit into
camel-4.22.xfrom
backport/25510-to-camel-4.22.x

Conversation

@davsclaus

Copy link
Copy Markdown
Contributor

Backport of #25510

Cherry-pick of #25510 onto camel-4.22.x.

Original PR: #25510 - CAMEL-22114: Fix PQC KeyStore tests on Java 25 (InvalidKeyException)
Original author: @gnodet
Target branch: camel-4.22.x

Original description

Summary

  • Fix InvalidKeyException: unknown private key passed to ML-DSA when using PQC KeyStore-based signing on Java 25
  • Re-encode JDK-native PQC keys through Bouncy Castle's KeyFactory after loading from a KeyStore or user-supplied KeyPair, transparently converting them to BC types
  • No-op on Java 17/21 where JKS always returns BC key instances

Root Cause

Java 25 natively supports ML-DSA (JEP 497). When a Bouncy Castle ML-DSA private key is stored in a JKS KeyStore and retrieved, the JDK's built-in ML-DSA KeyFactory deserializes it as a JDK-native ML-DSA key object. When this key is passed to BC's Signature.getInstance("ML-DSA", "BC").initSign(), BC does not recognize it.

See original PR for full details.


Claude Code on behalf of davsclaus

…25510)

* CAMEL-22114: Fix PQC KeyStore tests on Java 25 (InvalidKeyException)

On JDK 25+, the JKS KeyStore deserialises ML-DSA keys as JDK-native
key objects that Bouncy Castle's Signature SPI does not recognise,
causing InvalidKeyException: unknown private key passed to ML-DSA.

Re-encode keys through BC's KeyFactory after loading from a KeyStore
(or from user-supplied KeyPair). This transparently converts JDK-native
PQC keys into BC types and is a no-op for keys that are already BC
instances.

Fixes PQCSignatureOnlyKeyStoreTest and PQCSignatureWithKeyStoreTest
on Java 25.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* CAMEL-22114: Add dedicated regression test for Java 25 PQC key conversion

Add @EnabledForJreRange(min = JAVA_25) test that validates ML-DSA
sign+verify via JKS KeyStore works after the JDK-native key to BC
key conversion fix. Skipped on Java <25 where the conversion is a no-op.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Claus Ibsen <claus.ibsen@gmail.com>
@github-actions

Copy link
Copy Markdown
Contributor

🌟 Thank you for your contribution to the Apache Camel project! 🌟
🤖 CI automation will test this PR automatically.

🐫 Apache Camel Committers, please review the following items:

  • First-time contributors require MANUAL approval for the GitHub Actions to run
  • You can use the command /component-test (camel-)component-name1 (camel-)component-name2.. to request a test from the test bot although they are normally detected and executed by CI.
  • You can label PRs using skip-tests and test-dependents to fine-tune the checks executed by this PR.
  • Build and test logs are available in the summary page. Only Apache Camel committers have access to the summary.

⚠️ Be careful when sharing logs. Review their contents before sharing them publicly.

@github-actions

Copy link
Copy Markdown
Contributor

🧪 CI tested the following changed modules:

  • components/camel-pqc

🔬 Scalpel shadow comparison — Scalpel: 9 tested, 29 compile-only — current: 9 all tested

Maveniverse Scalpel detected 38 affected modules (current approach: 9).

⚠️ Modules only in Scalpel (29)
  • apache-camel
  • camel-allcomponents
  • camel-catalog
  • camel-catalog-console
  • camel-catalog-lucene
  • camel-catalog-maven
  • camel-catalog-suggest
  • camel-componentdsl
  • camel-csimple-maven-plugin
  • camel-endpointdsl
  • camel-endpointdsl-support
  • camel-itest
  • camel-jbang-core
  • camel-jbang-it
  • camel-jbang-main
  • camel-jbang-plugin-edit
  • camel-jbang-plugin-generate
  • camel-jbang-plugin-kubernetes
  • camel-jbang-plugin-test
  • camel-kamelet-main
  • camel-launcher
  • camel-report-maven-plugin
  • camel-route-parser
  • camel-yaml-dsl
  • camel-yaml-dsl-deserializers
  • camel-yaml-dsl-maven-plugin
  • coverage
  • docs
  • dummy-component

Skip-tests mode would test 9 modules (1 direct + 8 downstream), skip tests for 29 (generated code, meta-modules)

Modules Scalpel would test (9)
  • camel-jbang-mcp
  • camel-jbang-plugin-mcp
  • camel-jbang-plugin-route-parser
  • camel-jbang-plugin-tui
  • camel-jbang-plugin-validate
  • camel-launcher-container
  • camel-pqc
  • camel-yaml-dsl-validator
  • camel-yaml-dsl-validator-maven-plugin
Modules with tests skipped (29)
  • apache-camel
  • camel-allcomponents
  • camel-catalog
  • camel-catalog-console
  • camel-catalog-lucene
  • camel-catalog-maven
  • camel-catalog-suggest
  • camel-componentdsl
  • camel-csimple-maven-plugin
  • camel-endpointdsl
  • camel-endpointdsl-support
  • camel-itest
  • camel-jbang-core
  • camel-jbang-it
  • camel-jbang-main
  • camel-jbang-plugin-edit
  • camel-jbang-plugin-generate
  • camel-jbang-plugin-kubernetes
  • camel-jbang-plugin-test
  • camel-kamelet-main
  • camel-launcher
  • camel-report-maven-plugin
  • camel-route-parser
  • camel-yaml-dsl
  • camel-yaml-dsl-deserializers
  • camel-yaml-dsl-maven-plugin
  • coverage
  • docs
  • dummy-component

ℹ️ Shadow mode — Scalpel observes but does not affect test execution. Learn more

All tested modules (38 modules)
  • Camel :: All Components Sync point
  • Camel :: Assembly
  • Camel :: Catalog :: CSimple Maven Plugin (deprecated)
  • Camel :: Catalog :: Camel Catalog
  • Camel :: Catalog :: Camel Report Maven Plugin
  • Camel :: Catalog :: Camel Route Parser
  • Camel :: Catalog :: Console
  • Camel :: Catalog :: Dummy Component
  • Camel :: Catalog :: Lucene (deprecated)
  • Camel :: Catalog :: Maven
  • Camel :: Catalog :: Suggest
  • Camel :: Component DSL
  • Camel :: Coverage
  • Camel :: Docs
  • Camel :: Endpoint DSL
  • Camel :: Endpoint DSL :: Support
  • Camel :: Integration Tests
  • Camel :: JBang :: Core
  • Camel :: JBang :: Integration tests
  • Camel :: JBang :: MCP
  • Camel :: JBang :: Main
  • Camel :: JBang :: Plugin :: Edit
  • Camel :: JBang :: Plugin :: Generate
  • Camel :: JBang :: Plugin :: Kubernetes
  • Camel :: JBang :: Plugin :: MCP
  • Camel :: JBang :: Plugin :: Route Parser
  • Camel :: JBang :: Plugin :: TUI
  • Camel :: JBang :: Plugin :: Testing
  • Camel :: JBang :: Plugin :: Validate
  • Camel :: Kamelet Main
  • Camel :: Launcher
  • Camel :: Launcher :: Container
  • Camel :: PQC
  • Camel :: YAML DSL
  • Camel :: YAML DSL :: Deserializers
  • Camel :: YAML DSL :: Maven Plugins
  • Camel :: YAML DSL :: Validator
  • Camel :: YAML DSL :: Validator Maven Plugin

⚙️ View full build and test results

@gnodet gnodet 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.

Clean backport of #25510 to camel-4.22.x. The diff is byte-for-byte identical to the merged original. CI is green. The fix correctly re-encodes JDK-native PQC keys through BC's KeyFactory to avoid InvalidKeyException on Java 25+, with a well-gated regression test (@EnabledForJreRange(min = JAVA_25)).

📋 PR Metadata

Aspect Current Suggested
Labels components + bug
Milestone (none) 4.22.1

This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.

Claude Code on behalf of Guillaume Nodet

@davsclaus davsclaus added this to the 4.22.1 milestone Aug 26, 2026
@davsclaus davsclaus added the bug Something isn't working label Aug 26, 2026
@davsclaus davsclaus self-assigned this Aug 26, 2026
@davsclaus
davsclaus merged commit 85f7874 into camel-4.22.x Aug 26, 2026
4 checks passed
@davsclaus
davsclaus deleted the backport/25510-to-camel-4.22.x branch August 26, 2026 09:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants