davsclaus opened a new pull request, #31354: URL: https://github.com/apache/camel/pull/31354
## What was wrong - The signing and decrypting keys and the partner certificates of an AS2 endpoint (`signingPrivateKey`, `signingCertificateChain`, `decryptingPrivateKey`, `encryptingCertificateChain`, `validateSigningCertificateChain`) could only be set as Java objects. So a signed or encrypted exchange (the main point of AS2) could not be configured in YAML, XML, properties or tooling without Java code. - The `sslContextParameters` of the component, and the global ones with `useGlobalSslContextParameters`, were turned into an `SSLContext` in `doStart`. That was after `afterConfigureProperties` had already created the client, server and async MDN connections with no `SSLContext`, so they were never used: the client sent over plain http and the server listened without TLS. ## What changed New text options, resolved when the endpoint is created (before its connection): | Options | Set | |---|---| | `keyStore`, `keyStoreType` (PKCS12), `keyStorePassword`, `keyPassword`, `signingKeyAlias` | `signingPrivateKey`, `signingCertificateChain` | | `decryptingKeyAlias` (defaults to `signingKeyAlias`) | `decryptingPrivateKey` | | `trustStore`, `trustStoreType`, `trustStorePassword`, `encryptingCertificateAlias` / `encryptingCertificateResource` (PEM or DER) | `encryptingCertificateChain` | | `validateSigningCertificateAlias` / `validateSigningCertificateResource` | `validateSigningCertificateChain` | | `sslContextParameters` (endpoint) | `sslContext`; takes precedence over the component's | - The Java options still take precedence when they are set. - A wrong password, a missing alias or file, an alias without its store, or both an alias and a resource fail the endpoint with a message that names the option (and lists the keystore entries for a missing alias). No password is put in a message. - The options are configuration only, not arguments of the API methods, so a `CamelAs2.*` header cannot point them to another file. The resolved keys are handed to `client/send` through `interceptProperties`. They only fill in arguments that neither a header nor the endpoint set, because `AbstractApiEndpoint` takes its snapshot of the arguments before `afterConfigureProperties`. - All SSL resolution moved from `doStart` to `afterConfigureProperties`, before the connections are created: endpoint `sslContextParameters`, then the component's, then the global ones. - PEM certificates are read with the JDK `CertificateFactory`, without BouncyCastle. - `validateSigningCertificateChain` gets a description. - Docs: a "Keys and certificates" section with a YAML example of a signed and encrypted exchange with a signed receipt, and the TLS options. Catalog and endpoint DSL regenerated. - Upgrade guide (4.25): the `sslContextParameters` of the component are now used. ## Tests New `AS2KeyStoreOptionsTest`. The keys, keystores (PKCS12 and JKS), truststore and PEM files are generated at test time in a `@TempDir`, and the ports come from `AvailablePortFinder`: - a signed and encrypted round trip with a signed receipt, configured only with text options: the partner certificate from a truststore, and from a PEM file; - TLS with the endpoint `sslContextParameters` on the server and the component's on the client. It fails without the fix (the client connects over plain http); - the resolution: `decryptingKeyAlias` defaults to the signing entry, a JKS keystore with its own `keyPassword`, a PEM with two certificates, and an object option taking precedence; - 7 configuration errors and their messages. Ran the whole camel-as2 module (`mvn verify`): 112 unit tests and 52 ITs, all green. `AS2ClientSendTest.sendTheFilesOfAFolder` failed once and passed on retry. That is an existing order dependency (`sendFile()` leaves `message.edi` in the shared static inbox that the file route reads), not related to this change. Fixes https://issues.apache.org/jira/browse/CAMEL-21863 _Claude Code on behalf of davsclaus_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
