-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[node] Enable openssl legacy provider
This is to prevent a breaking change in a minor release of Kibana. The legacy provider can be disabled by removing `--openssl-legacy-provider` in `config/node.options`. [Node.js documentation](https://nodejs.org/docs/latest-v18.x/api/cli.html#--openssl-legacy-provider) [OpenSSL documentation](https://www.openssl.org/docs/man3.0/man7/OSSL_PROVIDER-legacy.html)
- Loading branch information
Showing
10 changed files
with
150 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
var branch = require('../../../package.json').branch; | ||
var docsBranch = branch.match(/^\d\.\d\d?$/) || 'current'; | ||
var openSSLLegacyProviderEnabled = require('./openssl_legacy_provider_enabled')(); | ||
|
||
if (openSSLLegacyProviderEnabled) { | ||
console.log( | ||
'Kibana is currently running with legacy OpenSSL providers enabled! For details and instructions on how to disable see https://www.elastic.co/guide/en/kibana/' + | ||
docsBranch + | ||
'/production.html#openssl-legacy-provider' | ||
); | ||
} |
33 changes: 33 additions & 0 deletions
33
src/setup_node_env/openssl_legacy_provider/openssl_legacy_provider_enabled.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
module.exports = function () { | ||
var nodeOptions = process.env.NODE_OPTIONS | ||
? process.env.NODE_OPTIONS.split(' ').filter(Boolean) | ||
: []; | ||
var execOptions = process.execArgv; | ||
|
||
var cliOpenSSLLegacyProvider = checkOpenSSLLegacyProvider(execOptions); | ||
var envOpenSSLLegacyProvider = checkOpenSSLLegacyProvider(nodeOptions); | ||
|
||
if (typeof cliOpenSSLLegacyProvider === 'boolean') return cliOpenSSLLegacyProvider; | ||
return Boolean(envOpenSSLLegacyProvider); | ||
}; | ||
|
||
function checkOpenSSLLegacyProvider(options) { | ||
var openSSLLegacyProvider = null; | ||
options.forEach(function (option) { | ||
if (option === '--openssl-legacy-provider') { | ||
openSSLLegacyProvider = true; | ||
} | ||
if (option === '--no-openssl-legacy-provider') { | ||
openSSLLegacyProvider = false; | ||
} | ||
}); | ||
return openSSLLegacyProvider; | ||
} |
77 changes: 77 additions & 0 deletions
77
src/setup_node_env/openssl_legacy_provider/openssl_legacy_provider_enabled.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
describe('openSSLLegacyProviderEnabled', function () { | ||
var env = process.env; | ||
var execArgv = process.execArgv; | ||
|
||
beforeEach(function () { | ||
jest.resetModules(); | ||
process.env.NODE_OPTIONS = ''; | ||
process.execArgv = []; | ||
}); | ||
|
||
afterAll(function () { | ||
process.env = env; | ||
process.execArgv = execArgv; | ||
}); | ||
|
||
describe('using NODE_OPTIONS', function () { | ||
it('should be enabled when --openssl-legacy-provider is set', function () { | ||
process.env.NODE_OPTIONS = '--openssl-legacy-provider'; | ||
expect(require('./openssl_legacy_provider_enabled')()).toBe(true); | ||
}); | ||
|
||
it('should be enabled when --openssl-legacy-provider is set after --no-openssl-legacy-provider', function () { | ||
process.env.NODE_OPTIONS = '--no-openssl-legacy-provider --openssl-legacy-provider'; | ||
expect(require('./openssl_legacy_provider_enabled')()).toBe(true); | ||
}); | ||
|
||
it('should be disabled by default', function () { | ||
process.env.NODE_OPTIONS = ''; | ||
expect(require('./openssl_legacy_provider_enabled')()).toBe(false); | ||
}); | ||
|
||
it('should be disabled when --no-openssl-legacy-provider is set', function () { | ||
process.env.NODE_OPTIONS = '--no-openssl-legacy-provider'; | ||
expect(require('./openssl_legacy_provider_enabled')()).toBe(false); | ||
}); | ||
|
||
it('should be disabled when --no-openssl-legacy-provider is set after --openssl-legacy-provider', function () { | ||
process.env.NODE_OPTIONS = '--openssl-legacy-provider --no-openssl-legacy-provider'; | ||
expect(require('./openssl_legacy_provider_enabled')()).toBe(false); | ||
}); | ||
}); | ||
|
||
describe('using exec arguments', function () { | ||
it('should be enabled when --openssl-legacy-provider is set', function () { | ||
process.execArgv = ['--openssl-legacy-provider']; | ||
expect(require('./openssl_legacy_provider_enabled')()).toBe(true); | ||
}); | ||
|
||
it('should be enabled when --openssl-legacy-provider is set after --no-openssl-legacy-provider', function () { | ||
process.execArgv = ['--no-openssl-legacy-provider', '--openssl-legacy-provider']; | ||
expect(require('./openssl_legacy_provider_enabled')()).toBe(true); | ||
}); | ||
|
||
it('should be disabled by default', function () { | ||
process.execArgv = []; | ||
expect(require('./openssl_legacy_provider_enabled')()).toBe(false); | ||
}); | ||
|
||
it('should be disabled when --no-openssl-legacy-provider is set', function () { | ||
process.execArgv = ['--no-openssl-legacy-provider']; | ||
expect(require('./openssl_legacy_provider_enabled')()).toBe(false); | ||
}); | ||
|
||
it('should be disabled when --no-openssl-legacy-provider is set after --openssl-legacy-provider', function () { | ||
process.execArgv = ['--openssl-legacy-provider', '--no-openssl-legacy-provider']; | ||
expect(require('./openssl_legacy_provider_enabled')()).toBe(false); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
"include": [ | ||
"harden/**/*", | ||
"root/**/*", | ||
"openssl_legacy_provider/**/*", | ||
"*.js", | ||
"*.ts", | ||
], | ||
|