Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion 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} [cryptdConnectionString] 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.
Comment thread
rosemaryy marked this conversation as resolved.
Outdated
*/

/**
Expand Down Expand Up @@ -134,7 +135,6 @@ const closeOperation = require('./operations/mongo_client_ops').closeOperation;
* @param {number} [options.minSize] If present, the connection pool will be initialized with minSize connections, and will never dip below minSize connections
* @param {boolean} [options.useNewUrlParser=false] Determines whether or not to use the new url parser. Enables the new, spec-compliant, url parser shipped in the core driver. This url parser fixes a number of problems with the original parser, and aims to outright replace that parser in the near future.
* @param {boolean} [options.useUnifiedTopology] Enables the new unified topology layer
* @param {string} [options.cryptdConnectionString] The connection string for mongocryptd
* @param {AutoEncryptionOptions} [options.autoEncryption] Optionally enable client side auto encryption
* @param {MongoClient~connectCallback} [callback] The command result callback
* @return {MongoClient} a MongoClient instance
Expand Down
14 changes: 8 additions & 6 deletions lib/operations/mongo_client_ops.js
Original file line number Diff line number Diff line change
Expand Up @@ -439,12 +439,14 @@ function createTopology(mongoClient, topologyType, options, callback) {
}

const MongoClient = loadClient();
let connectionString =
mongoClient.s.options.cryptdConnectionString != null
? mongoClient.s.options.cryptdConnectionString
: os.platform() === 'win32'
? 'mongodb://localhost:27020/?serverSelectionTimeoutMS=1000'
: 'mongodb://%2Ftmp%2Fmongocryptd.sock/?serverSelectionTimeoutMS=1000';
let connectionString;
if (mongoClient.s.options.autoEncryption.cryptdConnectionString != null) {
Comment thread
rosemaryy marked this conversation as resolved.
Outdated
connectionString = mongoClient.s.options.autoEncryption.cryptdConnectionString;
} 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