oscerd opened a new pull request, #31183: URL: https://github.com/apache/camel/pull/31183
## Summary [CAMEL-27917](https://issues.apache.org/jira/browse/CAMEL-27917), the second of the three follow-ups of [CAMEL-25675](https://issues.apache.org/jira/browse/CAMEL-25675), raised by davsclaus in the review of #29619. The TLS stores of the HashiCorp Vault client (`trustStore`, `keyStore`) were read once, when the client was created. The properties function and the secret refresh task keep their client for the life of the CamelContext. So a client certificate renewed in its file, as the Vault agent or cert-manager do with short-lived certificates, was used only after a restart. Until then, after the first certificate expired, the `cert` login failed, and on a Vault that requires client certificates every request failed. - **Checked before each request.** The client checks the modification time, size and identity of the files of the trust store and the key store (`HashicorpVaultTlsStores`). A file replaced by another one, such as a mounted Kubernetes secret, has another identity. - **A new TLS context.** When one changed, the client reads both stores again into a new TLS context and uses its socket factory from then on. The JDK keeps connections alive per socket factory, so the next request goes over a new connection, with a full handshake and the new stores, and no TLS session of the old stores is resumed. A check inside the key or trust manager would not have been enough, since a resumed session calls neither. - **A file being written** cannot be read when its file changes, so the previous stores stay in use, with a warning, until the file changes again. - No new option. The TLS section of the documentation describes the reload. The `sslContextParameters` of CAMEL-27916 (#31182) are built by the JSSE Utility and are not reloaded. ## Tests - `HashicorpVaultTlsStoresTest`, against a fake Vault over HTTPS, with copies of the test stores replaced while the client runs: - `readsTheTrustStoreAgainWhenItsFileChanges`: a trust store without the CA makes the next request fail the handshake, and putting the CA back makes it work again; - `presentsTheClientCertificateOfTheKeyStoreOnceItsFileChanges`: after the cert login with `CN=camel-client`, the key store is replaced with another certificate, and the next request presents `CN=camel-client-ec`; - `keepsTheStoresWhileTheChangedFileCannotBeRead`: a half-written trust store keeps the previous one, and the next change is read again. - `FakeVault.https(...)` can trust extra self-signed client certificates, for the key store test. - With the stores read once, as before (the socket factory fixed when the client is created), all three tests fail. - All 89 unit tests and all 38 integration tests of the module pass (Vault container, including `HashicorpVaultTlsIT` with `-dev-tls`). Full reactor build (`mvn clean install -DskipTests -DskipITs`): the only regenerated file is the catalog copy of the component documentation, committed. _Claude Code on behalf of oscerd_ 🤖 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]
