davsclaus opened a new pull request, #31401: URL: https://github.com/apache/camel/pull/31401
## Problem [CAMEL-28127](https://issues.apache.org/jira/browse/CAMEL-28127) With `secure=true` the `docker` component only checked that `certPath` was set, and handed `new LocalDirectorySSLConfig(certPath)` to docker-java. When the directory did not exist, or one of `ca.pem`, `cert.pem` and `key.pem` was missing (for example a typo in the path), docker-java gave no SSL context, and both transports (Netty and Jersey) built the client with an `http` scheme instead of `https`. Nothing failed when the client was created. The `tlsVerify` option (documented as "Check TLS") had no effect: Camel always sets a custom SSL config, and docker-java reads `dockerTlsVerify` only when none is set. So `tlsVerify=true` without `secure=true` created a client without TLS, unlike `DOCKER_TLS_VERIFY=1` for the Docker CLI. ## Change - `DockerClientFactory`: when `secure` or `tlsVerify` is enabled, the client uses the new `ssl.CertPathSslConfig`. - `CertPathSslConfig` checks that `certPath` is a directory with readable `ca.pem`, `cert.pem` and `key.pem`, and throws an `IllegalArgumentException` naming the missing file(s) otherwise. It delegates to `LocalDirectorySSLConfig` and throws a `DockerClientException` instead of returning no SSL context, which also covers the Netty transport that reads the files again for each new connection. - `tlsVerify=true` now enables TLS as `secure=true` does, with the same `certPath` requirement. - Option descriptions of `secure`, `certPath` and `tlsVerify`, and of the `CamelDockerTlsVerify` header, state the behaviour; `docker-component.adoc` has a new "Connecting with TLS" section. Generated files are regenerated. - Upgrade guide 4.25: `secure=true` with an incomplete `certPath` now fails when the client is created, and `tlsVerify=true` now enables TLS. ## Tests New `DockerClientFactoryTlsTest` (no Docker daemon; certificates generated with BouncyCastle in a JUnit `@TempDir`). The client is built for real with `DockerClientFactory.getDockerClient` and the default Netty `cmdExecFactory`, and a local server on a free port reads the first byte the client sends (`0x16` starts a TLS handshake, `G` a plain HTTP request): - `secureWithoutKeyPemFailsToCreateClient` - `secureWithMissingCertPathDirectoryFailsToCreateClient` - `tlsVerifyWithoutCertPathFailsToCreateClient` - `withoutSecureConnectsWithoutTls` - `secureWithCompleteCertPathConnectsWithTls` - `tlsVerifyWithoutSecureConnectsWithTls` - `secureConnectionFailsWhenKeyPemIsRemovedAfterTheClientIsCreated` Without the change in `DockerClientFactory`, five of them fail (no exception at client creation, and a plain HTTP request where TLS is expected); the other two pass both ways. The existing tests of the module pass. _Claude Code on behalf of Claus Ibsen_ 🤖 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]
