Skip to content

refactor(NODE-3922): remove behaviour around ocsp tls options #4577

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 9, 2025
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
7 changes: 1 addition & 6 deletions src/client-side-encryption/state_machine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,7 @@ const stateToString = new Map([
const INSECURE_TLS_OPTIONS = [
'tlsInsecure',
'tlsAllowInvalidCertificates',
'tlsAllowInvalidHostnames',

// These options are disallowed by the spec, so we explicitly filter them out if provided, even
// though the StateMachine does not declare support for these options.
'tlsDisableOCSPEndpointCheck',
'tlsDisableCertificateRevocationCheck'
'tlsAllowInvalidHostnames'
];

/**
Expand Down
5 changes: 0 additions & 5 deletions src/connection_string.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,6 @@ function checkTLSOptions(allOptions: CaseInsensitiveMap): void {
};
check('tlsInsecure', 'tlsAllowInvalidCertificates');
check('tlsInsecure', 'tlsAllowInvalidHostnames');
check('tlsInsecure', 'tlsDisableCertificateRevocationCheck');
check('tlsInsecure', 'tlsDisableOCSPEndpointCheck');
check('tlsAllowInvalidCertificates', 'tlsDisableCertificateRevocationCheck');
check('tlsAllowInvalidCertificates', 'tlsDisableOCSPEndpointCheck');
check('tlsDisableCertificateRevocationCheck', 'tlsDisableOCSPEndpointCheck');
}
function getBoolean(name: string, value: unknown): boolean {
if (typeof value === 'boolean') return value;
Expand Down
6 changes: 5 additions & 1 deletion test/unit/assorted/uri_options.spec.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ describe('URI option spec tests', function () {
// Skipped because this does not apply to Node
'Valid options specific to single-threaded drivers are parsed correctly',

// TODO(NODE-3922): have not implemented option support
// These options are specific to OCSP which the driver does not implement
// and will not be implemented in the future. Note that the other URI
// option tests that are testing these options are passing, simply because
// they are testing error conditions and the driver is throwing a MongoParseError
// when either of these options are provided.
'tlsDisableCertificateRevocationCheck can be set to true',
'tlsDisableCertificateRevocationCheck can be set to false',
'tlsDisableOCSPEndpointCheck can be set to true',
Expand Down
36 changes: 17 additions & 19 deletions test/unit/client-side-encryption/state_machine.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,27 +190,25 @@ describe('StateMachine', function () {

context('when tls options are provided', function () {
context('when the options are insecure', function () {
[
'tlsInsecure',
'tlsAllowInvalidCertificates',
'tlsAllowInvalidHostnames',
'tlsDisableOCSPEndpointCheck',
'tlsDisableCertificateRevocationCheck'
].forEach(function (option) {
context(`when the option is ${option}`, function () {
const stateMachine = new StateMachine({
tlsOptions: { aws: { [option]: true } }
} as any);
const request = new MockRequest(Buffer.from('foobar'), 500);

it('rejects with the validation error', function (done) {
stateMachine.kmsRequest(request).catch(err => {
expect(err.message).to.equal(`Insecure TLS options prohibited for aws: ${option}`);
done();
['tlsInsecure', 'tlsAllowInvalidCertificates', 'tlsAllowInvalidHostnames'].forEach(
function (option) {
context(`when the option is ${option}`, function () {
const stateMachine = new StateMachine({
tlsOptions: { aws: { [option]: true } }
} as any);
const request = new MockRequest(Buffer.from('foobar'), 500);

it('rejects with the validation error', function (done) {
stateMachine.kmsRequest(request).catch(err => {
expect(err.message).to.equal(
`Insecure TLS options prohibited for aws: ${option}`
);
done();
});
});
});
});
});
}
);
});

context('when the options are secure', function () {
Expand Down