davsclaus opened a new pull request, #3176:
URL: https://github.com/apache/camel-kamelets/pull/3176

   Part of #3170: the PostgreSQL, MySQL and MariaDB Kamelets (`-sink` and 
`-source`) take a `connectionProperties` option with extra settings for the 
JDBC driver.
   
   ### What was missing
   
   #3170 said a database that requires TLS could not be used. That is not quite 
right. With the drivers Camel uses today, these Kamelets already use TLS when 
the server offers it, so they connect to a TLS-only server. The exception is 
MariaDB with its 3.x driver.
   
   What was missing is a way to:
   
   - insist on TLS, so the Kamelet refuses a server without it;
   - check the certificate of the server;
   - set any other driver setting, such as a connect timeout.
   
   ### The option
   
   `connectionProperties` is an optional string of `name=value` pairs separated 
by `;`, such as `sslmode=require;connectTimeout=10`.
   
   - It sets the `connectionProperties` of the commons-dbcp2 data source, which 
passes them to the driver.
   - The user and password are still set by the pool, so this option cannot 
override them.
   - The examples are `sslmode=require` (PostgreSQL), `sslMode=REQUIRED` 
(MySQL) and `sslMode=trust` (MariaDB).
   - The description warns not to put a password in it: the value is not masked 
and appears in the startup log.
   - When it is not set, nothing changes.
   
   Each "Good to know" paragraph now says what happens with TLS when the option 
is not set. Each partial page has a "Connecting with TLS" section.
   
   ### Verification
   
   Tested with Camel JBang against PostgreSQL 17 (TLS required through 
`hostssl`), and against MySQL 8.4 and MariaDB 11.8 
(`require_secure_transport=ON`), as well as plain servers of each. In each case 
the sink inserted a row and the source read it.
   
   | Case | PostgreSQL | MySQL | MariaDB |
   |---|---|---|---|
   | TLS setting, TLS-only server | `sslmode=require`: works | 
`sslMode=REQUIRED`: works | `sslMode=trust`, and `REQUIRED`: works |
   | Two settings at once | Works | Works | Works |
   | Certificate check | `sslmode=verify-full;sslrootcert=...`: works | not 
tested | not tested |
   | Option unset, TLS-only server | Connects (TLS used when offered) | 
Connects | Driver 4.0.0 connects; driver 3.5.10 fails |
   | TLS turned off, TLS-only server | Fails: the setting reaches the driver | 
Fails | Fails |
   | Option unset, plain server | Works as before | Works as before | Works as 
before |
   
   `./mvnw clean install` passed twice, the first time with `-DskipTests`.
   
   ### Other SQL Kamelets, not changed
   
   - **`sqlserver-*`:** already have `encrypt` and `trustServerCertificate`.
   - **`oracle-database-*`:** need a `tcps://` URL and wallet settings for TLS, 
which is a bigger change.
   - **`aws-redshift-*`:** have the same gap, and the same one-line change 
would apply. They are left out because they could not be tested locally.
   - **`databricks-*`:** already take extra options.
   
   _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]

Reply via email to