yidaimi opened a new issue, #13199:
URL: https://github.com/apache/seatunnel/issues/13199

   ### Search before asking
   
   - [X] I had searched in the 
[feature](https://github.com/apache/seatunnel/issues?q=is%3Aissue+label%3A%22Feature%22)
 and found no similar feature requirement.
   
   ### Description
   
   The MongoDB sink cannot be configured to trust a CA that is not in the JDK 
trust store.
   
   - The Mongo Java driver ignores `tlsCAFile` (and 
`tlsAllowInvalidCertificates`) in the connection string, so `uri = 
"...?tls=true&tlsCAFile=..."` fails with `PKIX path building failed`.
   - The only working route today is a JVM-global `-Djavax.net.ssl.trustStore`. 
It applies to every job and connector in the same SeaTunnel process, replaces 
the default `cacerts` (breaking other connections to public-CA endpoints unless 
the stores are merged by hand), and needs a restart.
   
   This was confirmed against a live Amazon DocumentDB 5.0.2 endpoint (RDS CA) 
in #10443; see the compatibility matrix (T01-T05): 
https://github.com/yidaimi/seatunnel-cosmos-to-documentdb/blob/v0.2-delete_insert/test/sink-compat/compatibility-matrix.md
   
   **Proposal**
   
   Add an optional sink option `tls_ca_file` (same name as in the 
`AmazonDocumentDB` source): a path to a PEM file with one or more CA 
certificates. When set, the sink builds a per-job `SSLContext` trusting exactly 
those CAs and applies it through `MongoClientSettings.applyToSslSettings(...)`.
   
   Requirements, following the guidance in #10443:
   
   1. **One shared client-settings builder** used by every place the sink 
creates a client:
      - `MongodbSingleCollectionProvider` (writer and transaction committer),
      - `MongodbCatalog` (save mode handling, e.g. `DROP_DATA`, which also 
opens its own client),
      - `MongodbSinkDryRunValidator`.
   2. Hostname verification stays enabled; the existing URI option 
`tlsAllowInvalidHostnames` keeps its current meaning.
   3. No trust-all behavior and no change to JVM-global trust settings.
   4. Clear configuration errors for a missing, unreadable or certificate-less 
file; the file content and the URI are never logged.
   5. Backward compatible: without `tls_ca_file` the client is created exactly 
as today.
   6. No new bundled dependency (JDK `CertificateFactory` / `KeyStore` / 
`TrustManagerFactory`).
   
   **Tests**
   
   - Unit tests for the shared builder: CA loading (single and 
multi-certificate PEM), error cases, and that writer, catalog and dry-run 
validator all receive the same TLS settings.
   - E2E test with a TLS-enabled MongoDB test server using a CA generated for 
the test:
     - the configured CA succeeds;
     - an untrusted CA fails with a certificate path error;
     - a hostname mismatch still fails while `tls_ca_file` is set.
   
   Out of scope for this issue: the MongoDB source (it could reuse the same 
builder in a follow-up), client certificates (mutual TLS), and the unrelated 
buffer/retry default bug (#13198).
   
   ### Usage Scenario
   
   - Writing to Amazon DocumentDB, whose certificates are issued by the RDS CA 
(not in the JDK trust store), while other jobs on the same SeaTunnel cluster 
connect to public-CA endpoints.
   - Self-managed MongoDB clusters that use a private or corporate CA.
   - Several jobs on one cluster that need different CA bundles.
   
   ### Related issues
   
   - #10443 (Amazon DocumentDB sink row: per-job trust configuration was 
identified as the gap)
   - #12046 (`AmazonDocumentDB` source: builds a per-job `SSLContext` from 
`tls_ca_file`)
   - #13198 (MongoDB sink ignores declared buffer/retry defaults; separate fix)
   
   ### Are you willing to submit a PR?
   
   - [X] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [X] I agree to follow this project's [Code of 
Conduct](https://www.apache.org/foundation/policies/conduct)
   


-- 
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