[
https://issues.apache.org/jira/browse/CAMEL-27720?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Claus Ibsen updated CAMEL-27720:
--------------------------------
Fix Version/s: 4.25.0
(was: 4.24.0)
> camel-crypto: privateKey getter NPE, unknown bean names ignored, name not
> stored, metadata
> ------------------------------------------------------------------------------------------
>
> Key: CAMEL-27720
> URL: https://issues.apache.org/jira/browse/CAMEL-27720
> Project: Camel
> Issue Type: Bug
> Reporter: Claus Ibsen
> Priority: Minor
> Fix For: 4.25.0
>
>
> Found while improving the option descriptions of camel-crypto for CAMEL-23832
> (commit
> https://github.com/apache/camel/commit/afd7fc8b26810fe95e539976dc6fa4fc54044182).
> These are separate problems of the component; the descriptions commit only
> documents the current behavior.
> h4. 1. Reading the privateKey option fails with a NullPointerException when
> no password is set
> {{DigitalSignatureConfiguration.getPrivateKey()}} and {{getPrivateKey(String
> alias)}} call {{password.toCharArray()}}, so they throw a
> NullPointerException when the {{password}} option is not set, which is the
> normal case for a {{privateKey}} that does not come from a keystore.
> The generated {{DigitalSignatureEndpointConfigurer.getOptionValue()}} and
> {{DigitalSignatureComponentConfigurer.getOptionValue()}} call this getter for
> {{privateKey}}, as does {{DigitalSignatureEndpoint.getPrivateKey()}}.
> Anything that reads the option value through the configurer (for example
> nested property binding or tooling that lists option values) fails. The
> getter also returns the keystore entry of the alias instead of the value of
> the option.
> Proposed change: let {{getPrivateKey()}} return the {{privateKey}} field, and
> keep the keystore lookup in {{getPrivateKey(String, char[])}} with a
> null-safe password.
> h4. 2. Registry name options ignore a name that has no bean
> {{setKeystoreName()}}, {{setPrivateKeyName()}}, {{setPublicKeyName()}},
> {{setCertificateName()}} and {{setSecureRandomName()}} of
> {{DigitalSignatureConfiguration}} look the name up in the registry and do
> nothing when no bean of that name and type exists. A typo in, for example,
> {{keystoreName}} is only noticed on the first message, as "Cannot sign
> message as no Private Key has been supplied" from {{SigningProcessor}} or the
> matching error of {{VerifyingProcessor}}, which does not name the option.
> Proposed change: fail when the endpoint is created (or the producer starts)
> if a name option is set and no bean of that name exists.
> h4. 3. The name path option is never stored
> The {{name}} path option is marked {{required = true}}, but
> {{DigitalSignatureComponent.createEndpoint()}} only sets {{cryptoOperation}}
> from the remaining part of the URI and never calls {{setName()}}, so
> {{DigitalSignatureConfiguration.getName()}} is always null. Nothing reads it
> either.
> Proposed change: set it from the URI in {{createEndpoint()}}, so the option
> value matches the URI.
> h4. 4. signatureHeaderName has no defaultValue in the metadata
> {{DigitalSignatureConfiguration.getSignatureHeaderName()}} returns
> {{CamelDigitalSignature}} when the option is not set, but the {{@UriParam}}
> of {{signatureHeaderName}} has no {{defaultValue}}, so the catalog and the
> docs show no default.
> Proposed change: add {{defaultValue = "CamelDigitalSignature"}} (or
> initialize the field to {{DigitalSignatureConstants.SIGNATURE}}).
> h4. 5. secureRandom is marked as a secret
> The {{secureRandom}} option ({{java.security.SecureRandom}}) has {{security =
> "secret"}}, as does {{privateKeyName}}, which is only the name of a registry
> bean. Neither value is a secret, so tooling masks them for no reason.
> Proposed change: remove {{security = "secret"}} from these two options.
> _Claude Code on behalf of davsclaus_
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)