Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/mongo_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ const closeOperation = require('./operations/mongo_client_ops').closeOperation;
* @property {string} [kmsProviders.local.key] The master key used to encrypt/decrypt data keys
* @property {object} [schemaMap] A map of namespaces to a local JSON schema for encryption
* @property {boolean} [bypassAutoEncryption] Allows the user to bypass auto encryption, maintaining implicit decryption
* @param {string} [extraOptions.mongocryptURI] A local process the driver communicates with to determine how to encrypt values in a command. Defaults to "mongodb://%2Fvar%2Fmongocryptd.sock" if domain sockets are available or "mongodb://localhost:27020" otherwise.
*/

/**
Expand Down
12 changes: 8 additions & 4 deletions lib/operations/mongo_client_ops.js
Original file line number Diff line number Diff line change
Expand Up @@ -439,10 +439,14 @@ function createTopology(mongoClient, topologyType, options, callback) {
}

const MongoClient = loadClient();
const connectionString =
os.platform() === 'win32'
? 'mongodb://localhost:27020/?serverSelectionTimeoutMS=1000'
: 'mongodb://%2Ftmp%2Fmongocryptd.sock/?serverSelectionTimeoutMS=1000';
let connectionString;
if (options.autoEncryption.extraOptions && options.autoEncryption.extraOptions.mongocryptURI) {
connectionString = options.autoEncryption.extraOptions.mongocryptURI;
} else if (os.platform() === 'win32') {
connectionString = 'mongodb://localhost:27020/?serverSelectionTimeoutMS=1000';
} else {
connectionString = 'mongodb://%2Ftmp%2Fmongocryptd.sock/?serverSelectionTimeoutMS=1000';
}

const mongocryptdClient = new MongoClient(connectionString, { useUnifiedTopology: true });
mongocryptdClient.connect(err => {
Expand Down