Skip to content

Commit ee56c8e

Browse files
authored
feat(NODE-5376)!: remove deprecated ssl options (#3755)
1 parent de158b2 commit ee56c8e

File tree

8 files changed

+47
-157
lines changed

8 files changed

+47
-157
lines changed

Diff for: etc/notes/CHANGES_6.0.0.md

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Changes in the MongoDB Node.js Driver v6
2+
3+
## About
4+
5+
The following is a detailed collection of the changes in the major v6 release of the `mongodb` package for Node.js.
6+
7+
## Contents
8+
9+
- [Changes](#changes)
10+
- [Deprecated SSL options removed](#deprecated-ssl-options-removed)
11+
12+
## Changes
13+
14+
### Deprecated SSL options removed
15+
16+
The following deprecated SSL/TLS options have now been removed (-> indicating the corresponding option):
17+
18+
- `sslCA` -> `tlsCAFile`
19+
- `sslCRL`
20+
- `sslCert` -> `tlsCertificateKeyFile`
21+
- `sslKey` -> `tlsCertificateKeyFile`
22+
- `sslPass` -> `tlsCertificateKeyFilePassword`
23+
- `sslValidate` -> `tlsAllowInvalidCertificates`
24+
- `tlsCertificateFile` -> `tlsCertificateKeyFile`

Diff for: src/connection_string.ts

-59
Original file line numberDiff line numberDiff line change
@@ -347,13 +347,6 @@ export function parseOptions(
347347
allProvidedOptions.set(key, values);
348348
}
349349

350-
if (
351-
allProvidedOptions.has('tlsCertificateKeyFile') &&
352-
!allProvidedOptions.has('tlsCertificateFile')
353-
) {
354-
allProvidedOptions.set('tlsCertificateFile', allProvidedOptions.get('tlsCertificateKeyFile'));
355-
}
356-
357350
if (allProvidedOptions.has('tls') || allProvidedOptions.has('ssl')) {
358351
const tlsAndSslOpts = (allProvidedOptions.get('tls') || [])
359352
.concat(allProvidedOptions.get('ssl') || [])
@@ -1096,50 +1089,6 @@ export const OPTIONS = {
10961089
target: 'tls',
10971090
type: 'boolean'
10981091
},
1099-
sslCA: {
1100-
deprecated:
1101-
'sslCA is deprecated and will be removed in the next major version. Please use tlsCAFile instead.',
1102-
target: 'ca',
1103-
transform({ values: [value] }) {
1104-
return fs.readFileSync(String(value), { encoding: 'ascii' });
1105-
}
1106-
},
1107-
sslCRL: {
1108-
deprecated:
1109-
'sslCRL is deprecated and will be removed in the next major version. Please use tlsCertificateKeyFile instead.',
1110-
target: 'crl',
1111-
transform({ values: [value] }) {
1112-
return fs.readFileSync(String(value), { encoding: 'ascii' });
1113-
}
1114-
},
1115-
sslCert: {
1116-
deprecated:
1117-
'sslCert is deprecated and will be removed in the next major version. Please use tlsCertificateKeyFile instead.',
1118-
target: 'cert',
1119-
transform({ values: [value] }) {
1120-
return fs.readFileSync(String(value), { encoding: 'ascii' });
1121-
}
1122-
},
1123-
sslKey: {
1124-
deprecated:
1125-
'sslKey is deprecated and will be removed in the next major version. Please use tlsCertificateKeyFile instead.',
1126-
target: 'key',
1127-
transform({ values: [value] }) {
1128-
return fs.readFileSync(String(value), { encoding: 'ascii' });
1129-
}
1130-
},
1131-
sslPass: {
1132-
deprecated:
1133-
'sslPass is deprecated and will be removed in the next major version. Please use tlsCertificateKeyFilePassword instead.',
1134-
target: 'passphrase',
1135-
type: 'string'
1136-
},
1137-
sslValidate: {
1138-
deprecated:
1139-
'sslValidate is deprecated and will be removed in the next major version. Please use tlsAllowInvalidCertificates instead.',
1140-
target: 'rejectUnauthorized',
1141-
type: 'boolean'
1142-
},
11431092
tls: {
11441093
type: 'boolean'
11451094
},
@@ -1163,14 +1112,6 @@ export const OPTIONS = {
11631112
return fs.readFileSync(String(value), { encoding: 'ascii' });
11641113
}
11651114
},
1166-
tlsCertificateFile: {
1167-
deprecated:
1168-
'tlsCertificateFile is deprecated and will be removed in the next major version. Please use tlsCertificateKeyFile instead.',
1169-
target: 'cert',
1170-
transform({ values: [value] }) {
1171-
return fs.readFileSync(String(value), { encoding: 'ascii' });
1172-
}
1173-
},
11741115
tlsCertificateKeyFile: {
11751116
target: 'key',
11761117
transform({ values: [value] }) {

Diff for: src/deps.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -208,9 +208,7 @@ export type AutoEncryptionLoggerLevel =
208208
export interface AutoEncryptionTlsOptions {
209209
/**
210210
* Specifies the location of a local .pem file that contains
211-
* either the client's TLS/SSL certificate and key or only the
212-
* client's TLS/SSL key when tlsCertificateFile is used to
213-
* provide the certificate.
211+
* either the client's TLS/SSL certificate and key.
214212
*/
215213
tlsCertificateKeyFile?: string;
216214
/**

Diff for: src/mongo_client.ts

+10-46
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,7 @@ export interface MongoClientOptions extends BSONSerializeOptions, SupportedNodeC
108108
tls?: boolean;
109109
/** A boolean to enable or disables TLS/SSL for the connection. (The ssl option is equivalent to the tls option.) */
110110
ssl?: boolean;
111-
/**
112-
* Specifies the location of a local TLS Certificate
113-
* @deprecated Will be removed in the next major version. Please use tlsCertificateKeyFile instead.
114-
*/
115-
tlsCertificateFile?: string;
116-
/** Specifies the location of a local .pem file that contains either the client's TLS/SSL certificate and key or only the client's TLS/SSL key when tlsCertificateFile is used to provide the certificate. */
111+
/** Specifies the location of a local .pem file that contains either the client's TLS/SSL certificate and key. */
117112
tlsCertificateKeyFile?: string;
118113
/** Specifies the password to de-crypt the tlsCertificateKeyFile. */
119114
tlsCertificateKeyFilePassword?: string;
@@ -211,36 +206,6 @@ export interface MongoClientOptions extends BSONSerializeOptions, SupportedNodeC
211206
* @see https://www.mongodb.com/docs/manual/reference/write-concern/
212207
*/
213208
writeConcern?: WriteConcern | WriteConcernSettings;
214-
/**
215-
* Validate mongod server certificate against Certificate Authority
216-
* @deprecated Will be removed in the next major version. Please use tlsAllowInvalidCertificates instead.
217-
*/
218-
sslValidate?: boolean;
219-
/**
220-
* SSL Certificate file path.
221-
* @deprecated Will be removed in the next major version. Please use tlsCAFile instead.
222-
*/
223-
sslCA?: string;
224-
/**
225-
* SSL Certificate file path.
226-
* @deprecated Will be removed in the next major version. Please use tlsCertificateKeyFile instead.
227-
*/
228-
sslCert?: string;
229-
/**
230-
* SSL Key file file path.
231-
* @deprecated Will be removed in the next major version. Please use tlsCertificateKeyFile instead.
232-
*/
233-
sslKey?: string;
234-
/**
235-
* SSL Certificate pass phrase.
236-
* @deprecated Will be removed in the next major version. Please use tlsCertificateKeyFilePassword instead.
237-
*/
238-
sslPass?: string;
239-
/**
240-
* SSL Certificate revocation list file path.
241-
* @deprecated Will be removed in the next major version. Please use tlsCertificateKeyFile instead.
242-
*/
243-
sslCRL?: string;
244209
/** TCP Connection no delay */
245210
noDelay?: boolean;
246211
/** @deprecated TCP Connection keep alive enabled. Will not be able to turn off in the future. */
@@ -805,16 +770,15 @@ export interface MongoOptions
805770
*
806771
* ### Additional options:
807772
*
808-
* | nodejs native option | driver spec compliant option name | legacy option name | driver option type |
809-
* |:----------------------|:----------------------------------------------|:-------------------|:-------------------|
810-
* | `ca` | `tlsCAFile` | `sslCA` | `string` |
811-
* | `crl` | N/A | `sslCRL` | `string` |
812-
* | `cert` | `tlsCertificateFile`, `tlsCertificateKeyFile` | `sslCert` | `string` |
813-
* | `key` | `tlsCertificateKeyFile` | `sslKey` | `string` |
814-
* | `passphrase` | `tlsCertificateKeyFilePassword` | `sslPass` | `string` |
815-
* | `rejectUnauthorized` | `tlsAllowInvalidCertificates` | `sslValidate` | `boolean` |
816-
* | `checkServerIdentity` | `tlsAllowInvalidHostnames` | N/A | `boolean` |
817-
* | see note below | `tlsInsecure` | N/A | `boolean` |
773+
* | nodejs native option | driver spec compliant option name | driver option type |
774+
* |:----------------------|:----------------------------------------------|:-------------------|
775+
* | `ca` | `tlsCAFile` | `string` |
776+
* | `crl` | N/A | `string` |
777+
* | `key` | `tlsCertificateKeyFile` | `string` |
778+
* | `passphrase` | `tlsCertificateKeyFilePassword` | `string` |
779+
* | `rejectUnauthorized` | `tlsAllowInvalidCertificates` | `boolean` |
780+
* | `checkServerIdentity` | `tlsAllowInvalidHostnames` | `boolean` |
781+
* | see note below | `tlsInsecure` | `boolean` |
818782
*
819783
* If `tlsInsecure` is set to `true`, then it will set the node native options `checkServerIdentity`
820784
* to a no-op and `rejectUnauthorized` to `false`.

Diff for: test/integration/node-specific/bson-options/ignore_undefined.test.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,7 @@ describe('Ignore Undefined', function () {
5656
const client = configuration.newClient(
5757
{},
5858
{
59-
ignoreUndefined: true,
60-
sslValidate: false
59+
ignoreUndefined: true
6160
}
6261
);
6362

Diff for: test/types/community/changes_from_36.test-d.ts

-11
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,6 @@ expectNotType<boolean>(options.readPreference);
2525
expectNotType<{}>(options.pkFactory);
2626
// .checkServerIdentity cannot be `true`
2727
expectNotType<true>(options.checkServerIdentity);
28-
// .sslCA cannot be string[]
29-
expectNotType<string[]>(options.sslCA);
30-
// .sslCRL cannot be string[]
31-
expectNotType<string[]>(options.sslCRL);
32-
// .sslCert cannot be a Buffer
33-
expectNotType<Buffer>(options.sslCert);
34-
// .sslKey cannot be a Buffer
35-
expectNotType<Buffer>(options.sslKey);
36-
// .sslPass cannot be a Buffer
37-
expectNotType<Buffer>(options.sslPass);
3828

3929
// Legacy option kept
4030
expectType<PropExists<MongoClientOptions, 'w'>>(true);
@@ -60,7 +50,6 @@ expectType<ReadPreferenceMode | ReadPreference | undefined>(options.readPreferen
6050
expectType<boolean | undefined>(options.promoteValues);
6151
expectType<number | undefined>(options.family);
6252
expectType<boolean | undefined>(options.ssl);
63-
expectType<boolean | undefined>(options.sslValidate);
6453
expectAssignable<((host: string, cert: PeerCertificate) => Error | undefined) | undefined>(
6554
options.checkServerIdentity
6655
);

Diff for: test/types/community/client.test-d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const options: MongoClientOptions = {
2525
maxPoolSize: 1,
2626
family: 4,
2727
ssl: true,
28-
sslValidate: false,
28+
tlsAllowInvalidCertificates: false,
2929
// eslint-disable-next-line @typescript-eslint/no-unused-vars
3030
checkServerIdentity(host, cert) {
3131
return undefined;

Diff for: test/unit/mongo_client.test.js

+10-35
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,8 @@ describe('MongoOptions', function () {
3434
fs.closeSync(fs.openSync(filename, 'w'));
3535
const options = parseOptions('mongodb://localhost:27017/?ssl=true', {
3636
tlsCertificateKeyFile: filename,
37-
tlsCertificateFile: filename,
3837
tlsCAFile: filename,
39-
sslCRL: filename,
40-
tlsCertificateKeyFilePassword: 'tlsCertificateKeyFilePassword',
41-
sslValidate: false
38+
tlsCertificateKeyFilePassword: 'tlsCertificateKeyFilePassword'
4239
});
4340
fs.unlinkSync(filename);
4441

@@ -47,27 +44,24 @@ describe('MongoOptions', function () {
4744
*
4845
* ### Additional options:
4946
*
50-
* | nodejs option | MongoDB equivalent | type |
51-
* |:---------------------|----------------------------------------------------|:---------------------------------------|
52-
* | `ca` | sslCA, tlsCAFile | `string \| Buffer \| Buffer[]` |
53-
* | `crl` | sslCRL | `string \| Buffer \| Buffer[]` |
54-
* | `cert` | sslCert, tlsCertificateFile | `string \| Buffer \| Buffer[]` |
55-
* | `key` | sslKey, tlsCertificateKeyFile | `string \| Buffer \| KeyObject[]` |
56-
* | `passphrase` | sslPass, tlsCertificateKeyFilePassword | `string` |
57-
* | `rejectUnauthorized` | sslValidate | `boolean` |
47+
* | nodejs native option | driver spec compliant option name | driver option type |
48+
* |:----------------------|:----------------------------------------------|:-------------------|
49+
* | `ca` | `tlsCAFile` | `string` |
50+
* | `crl` | N/A | `string` |
51+
* | `key` | `tlsCertificateKeyFile` | `string` |
52+
* | `passphrase` | `tlsCertificateKeyFilePassword` | `string` |
53+
* | `rejectUnauthorized` | `tlsAllowInvalidCertificates` | `boolean` |
54+
* | `checkServerIdentity` | `tlsAllowInvalidHostnames` | `boolean` |
55+
* | see note below | `tlsInsecure` | `boolean` |
5856
*
5957
*/
6058
expect(options).to.not.have.property('tlsCertificateKeyFile');
6159
expect(options).to.not.have.property('tlsCAFile');
62-
expect(options).to.not.have.property('sslCRL');
6360
expect(options).to.not.have.property('tlsCertificateKeyFilePassword');
6461
expect(options).has.property('ca', '');
65-
expect(options).has.property('crl', '');
66-
expect(options).has.property('cert', '');
6762
expect(options).has.property('key');
6863
expect(options.key).has.length(0);
6964
expect(options).has.property('passphrase', 'tlsCertificateKeyFilePassword');
70-
expect(options).has.property('rejectUnauthorized', false);
7165
expect(options).has.property('tls', true);
7266
});
7367

@@ -126,8 +120,6 @@ describe('MongoOptions', function () {
126120
serverApi: { version: '1' },
127121
socketTimeoutMS: 3,
128122
ssl: true,
129-
sslPass: 'pass',
130-
sslValidate: true,
131123
tls: true,
132124
tlsAllowInvalidCertificates: true,
133125
tlsAllowInvalidHostnames: true,
@@ -404,28 +396,11 @@ describe('MongoOptions', function () {
404396
const optsFromObject = parseOptions('mongodb://localhost/', {
405397
tlsCertificateKeyFile: 'testCertKey.pem'
406398
});
407-
expect(optsFromObject).to.have.property('cert', 'cert key');
408399
expect(optsFromObject).to.have.property('key', 'cert key');
409400

410401
const optsFromUri = parseOptions('mongodb://localhost?tlsCertificateKeyFile=testCertKey.pem');
411-
expect(optsFromUri).to.have.property('cert', 'cert key');
412402
expect(optsFromUri).to.have.property('key', 'cert key');
413403
});
414-
415-
it('correctly sets the cert and key if both tlsCertificateKeyFile and tlsCertificateFile is provided', function () {
416-
const optsFromObject = parseOptions('mongodb://localhost/', {
417-
tlsCertificateKeyFile: 'testKey.pem',
418-
tlsCertificateFile: 'testCert.pem'
419-
});
420-
expect(optsFromObject).to.have.property('cert', 'test cert');
421-
expect(optsFromObject).to.have.property('key', 'test key');
422-
423-
const optsFromUri = parseOptions(
424-
'mongodb://localhost?tlsCertificateKeyFile=testKey.pem&tlsCertificateFile=testCert.pem'
425-
);
426-
expect(optsFromUri).to.have.property('cert', 'test cert');
427-
expect(optsFromUri).to.have.property('key', 'test key');
428-
});
429404
});
430405

431406
it('throws an error if multiple tls parameters are not all set to the same value', () => {

0 commit comments

Comments
 (0)