Skip to content

Commit

Permalink
fix(encryption): autoEncryption must error on mongodb < 4.2
Browse files Browse the repository at this point in the history
Fixes NODE-2334
  • Loading branch information
daprahamian authored Nov 18, 2019
1 parent 7cd6ad6 commit c274615
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/core/wireprotocol/command.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const databaseNamespace = require('./shared').databaseNamespace;
const isTransactionCommand = require('../transactions').isTransactionCommand;
const applySession = require('../sessions').applySession;
const MongoNetworkError = require('../error').MongoNetworkError;
const maxWireVersion = require('../utils').maxWireVersion;

function isClientEncryptionEnabled(server) {
return server.autoEncrypter;
Expand All @@ -27,6 +28,12 @@ function command(server, ns, cmd, options, callback) {
return;
}

const wireVersion = maxWireVersion(server);
if (typeof wireVersion !== 'number' || wireVersion < 8) {
callback(new MongoError('Auto-encryption requires a minimum MongoDB version of 4.2'));
return;
}

_cryptCommand(server, ns, cmd, options, callback);
}

Expand Down

0 comments on commit c274615

Please sign in to comment.