Claus Ibsen created CAMEL-27203:
-----------------------------------
Summary: camel-pqc - allow a key store from a file, and fail fast
without keyPairAlias
Key: CAMEL-27203
URL: https://issues.apache.org/jira/browse/CAMEL-27203
Project: Camel
Issue Type: Improvement
Components: camel-pqc
Reporter: Claus Ibsen
To sign, verify or decapsulate with a persistent key pair, the PQC endpoint
takes {{keyStore}} (a {{java.security.KeyStore}} object), {{keyPairAlias}} and
{{keyStorePassword}}, or a {{keyPair}} object. Both are objects, so a route in
YAML or a Kamelet needs a bean that loads the key store (for example a one-line
Groovy script bean calling {{KeyStore.getInstance(new File(...), password)}}).
There is no way to give a key store file and type as plain options.
h3. Suggestion 1: key store from a resource
Add options such as {{keyStoreResource}} (file:/classpath: resource) and
{{keyStoreType}} (default PKCS12), or accept a {{KeyStoreParameters}} like
other components, and load the key store at producer start when {{keyStore}} is
not set. Then a key store made with {{keytool}} (ML-DSA-65 or ML-KEM-768) can
be used with options only:
{noformat}
pqc:sign?operation=sign&signatureAlgorithm=MLDSA&keyStoreResource=file:pqc.p12&keyStoreType=PKCS12&keyPairAlias=sig&keyStorePassword=...
{noformat}
h3. Suggestion 2: fail at start when a key store has no alias
{{keyStore}} is autowired. When the registry has exactly one {{KeyStore}} bean,
every PQC endpoint picks it up, even without {{keyStore}} in the URI. Then
{{PQCComponent}} skips the default key material (because a key store is set),
but {{PQCProducer.doStart}} only builds the key pair when {{keyPairAlias}} and
{{keyStorePassword}} are set as well, so {{keyPair}} stays null and every
message fails:
{noformat}
java.lang.NullPointerException: ... this.keyPair is null
{noformat}
The producer should fail at start with a clear message when {{keyStore}} is set
but {{keyPairAlias}} or {{keyStorePassword}} is missing (or when the alias is
not in the key store).
h3. Where
*
{{components/camel-pqc/src/main/java/org/apache/camel/component/pqc/PQCConfiguration.java}}:
{{keyStore}} ({{autowired = true}}), {{keyPairAlias}}, {{keyStorePassword}}
*
{{components/camel-pqc/src/main/java/org/apache/camel/component/pqc/PQCProducer.java}}:
{{doStart}}, the {{if (keyStore != null && keyPairAlias != null &&
keyStorePassword != null)}} block, else {{keyPair =
getConfiguration().getKeyPair()}}
*
{{components/camel-pqc/src/main/java/org/apache/camel/component/pqc/PQCComponent.java}}:
the default material is skipped when {{keyStore}} or {{keyPairAlias}} is set
Found while adding key store options to the {{pqc-signature-action}} and
{{pqc-kem-action}} Kamelets.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)