Skip to content

feature/add-tls - #11

Merged
cedricve merged 1 commit into
mainfrom
feature/add-tls
Jun 2, 2026
Merged

cedricve merged 1 commit into
mainfrom
feature/add-tls

Conversation

@cedricve

@cedricve cedricve commented Jun 2, 2026 •

Copy link
Copy Markdown
Member

Description

Motivation

The database client currently cannot connect to MongoDB-compatible services that enforce in-transit encryption, such as AWS DocumentDB. This makes the library unusable in many production environments where TLS is mandatory.

Why this improves the project

This PR adds first-class TLS/SSL support to the MongoDB options builder, including custom CA bundles and an explicit escape hatch for local testing. It enables secure-by-default connections, unblocks DocumentDB and other managed services, and documents the setup clearly in the README. The API remains backward compatible while making the library viable for real-world, security-conscious deployments.

Add TLS configuration options to MongoOptions (TLS, TLSCAFile, TLSInsecureSkipVerify) and corresponding builder setters. Implement applyTLSConfig to attach a tls.Config to the mongo client options, load and parse a PEM CA bundle (with error handling) and implicitly enable TLS when a CA file is provided. Wire TLS config into newMongoClientFromURI and newMongoClientFromComponents. Add unit tests for the new setters and behavior, and update README with an example and option table for TLS usage (e.g. AWS DocumentDB).
@codecov

codecov Bot commented Jun 2, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 45.16129% with 17 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pkg/database/mongodb.go 45.16% 15 Missing and 2 partials ⚠️

📢 Thoughts on this report? Let us know!

@cedricve
cedricve merged commit 33fbf85 into main Jun 2, 2026
6 checks passed
@cedricve
cedricve deleted the feature/add-tls branch June 2, 2026 20:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant