Skip to content

Conversation

@durran
Copy link
Member

@durran durran commented Jul 8, 2025

Description

Allows users to pass a secureContext option to the TLS options in client encryption and auto encryption.

What is changing?

  • Allows a secureContext option to the tlsOptions:<provider> option in autoEncryption options on the MongoClient or the options for ClientEncryption.
  • Adds tests that ensure a secureContext option takes precedence over the driver tls* options, that the tls* options aren't attempted to be read from the file, and that it works end-to-end.
Is there new documentation needed for these changes?

Yes, update the MongoDB manual to show the precedence of the options.

What is the motivation for this change?

NODE-4179

Release Highlight

Allow a secureContext for Auto Encryption and Client Encryption TLS options

This can be provided in the tlsOptions option both both objects.

import * as tls from 'tls'; import { ClientEncryption, MongoClient } from 'mongodb'; const caFile = await fs.readFile(process.env.CSFLE_TLS_CA_FILE); const certFile = await fs.readFile(process.env.CSFLE_TLS_CLIENT_CERT_FILE); const secureContextOptions = { ca: caFile, key: certFile, cert: certFile }; const options = { keyVaultNamespace: 'db.coll', kmsProviders: { aws: {} } }, tlsOptions: { aws: { secureContext: tls.createSecureContext(secureContextOptions), } } }; const client = this.configuration.newClient({}, { autoEncryption: { ...options, schemaMap } }); const clientEncryption = new ClientEncryption(client, options);

Double check the following

  • Ran npm run check:lint script
  • Self-review completed using the steps outlined here
  • PR title follows the correct format: type(NODE-xxxx)[!]: description
    • Example: feat(NODE-1234)!: rewriting everything in coffeescript
  • Changes are covered by tests
  • New TODOs have a related JIRA ticket
@durran durran force-pushed the NODE-4179 branch 4 times, most recently from 75cb045 to 68309a1 Compare July 9, 2025 14:44
@durran durran marked this pull request as ready for review July 9, 2025 15:22
@durran durran requested a review from a team as a code owner July 9, 2025 15:22
@dariakp dariakp self-assigned this Jul 9, 2025
@dariakp dariakp added the Primary Review In Review with primary reviewer, not yet ready for team's eyes label Jul 9, 2025
@dariakp dariakp requested a review from addaleax July 9, 2025 20:17
@durran durran requested a review from dariakp July 10, 2025 14:56
@durran durran requested a review from dariakp July 11, 2025 16:16
@dariakp dariakp added Team Review Needs review from team and removed Primary Review In Review with primary reviewer, not yet ready for team's eyes labels Jul 22, 2025
@durran durran requested a review from dariakp July 22, 2025 23:26
@dariakp dariakp merged commit 0ea6eaa into main Jul 23, 2025
28 of 29 checks passed
@dariakp dariakp deleted the NODE-4179 branch July 23, 2025 13:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Team Review Needs review from team

5 participants