Skip to content

Commit c274615

Browse files
authored
fix(encryption): autoEncryption must error on mongodb < 4.2
Fixes NODE-2334
1 parent 7cd6ad6 commit c274615

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

lib/core/wireprotocol/command.js

+7
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const databaseNamespace = require('./shared').databaseNamespace;
99
const isTransactionCommand = require('../transactions').isTransactionCommand;
1010
const applySession = require('../sessions').applySession;
1111
const MongoNetworkError = require('../error').MongoNetworkError;
12+
const maxWireVersion = require('../utils').maxWireVersion;
1213

1314
function isClientEncryptionEnabled(server) {
1415
return server.autoEncrypter;
@@ -27,6 +28,12 @@ function command(server, ns, cmd, options, callback) {
2728
return;
2829
}
2930

31+
const wireVersion = maxWireVersion(server);
32+
if (typeof wireVersion !== 'number' || wireVersion < 8) {
33+
callback(new MongoError('Auto-encryption requires a minimum MongoDB version of 4.2'));
34+
return;
35+
}
36+
3037
_cryptCommand(server, ns, cmd, options, callback);
3138
}
3239

0 commit comments

Comments
 (0)