-
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 (#163190)
This is to prevent a breaking change in a minor release of Kibana due to an underlying upgrade of Node.js to v18. 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) --------- Co-authored-by: Thomas Watson <[email protected]> (cherry picked from commit aebd6f3)
- Loading branch information
Showing
10 changed files
with
132 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' | ||
); | ||
} |
14 changes: 14 additions & 0 deletions
14
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,14 @@ | ||
/* | ||
* 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 crypto = require('crypto'); | ||
|
||
// The blowfish cipher is only available when node is running with the --openssl-legacy-provider flag | ||
module.exports = function () { | ||
return crypto.getCiphers().includes('blowfish'); | ||
}; |
78 changes: 78 additions & 0 deletions
78
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,78 @@ | ||
/* | ||
* 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 spawnSync = require('child_process').spawnSync; | ||
|
||
describe('openSSLLegacyProviderEnabled', function () { | ||
function runLegacyProviderCheck(execOptions, nodeOptions) { | ||
var result = spawnSync( | ||
process.execPath, | ||
(execOptions ? execOptions.split(' ') : []).concat([ | ||
'-p', | ||
"require('./openssl_legacy_provider_enabled')()", | ||
]), | ||
{ | ||
env: { | ||
NODE_OPTIONS: nodeOptions || '', | ||
}, | ||
encoding: 'utf-8', | ||
cwd: __dirname, | ||
} | ||
); | ||
var stdout = result.stdout.trim(); | ||
return stdout === 'true'; | ||
} | ||
|
||
it('should be disabled by default', function () { | ||
expect(runLegacyProviderCheck()).toBe(false); | ||
}); | ||
|
||
describe('using NODE_OPTIONS', function () { | ||
it('should be enabled when --openssl-legacy-provider is set', function () { | ||
expect(runLegacyProviderCheck(null, '--openssl-legacy-provider')).toBe(true); | ||
}); | ||
|
||
it('should be enabled when --openssl-legacy-provider is set after --no-openssl-legacy-provider', function () { | ||
expect( | ||
runLegacyProviderCheck(null, '--no-openssl-legacy-provider --openssl-legacy-provider') | ||
).toBe(true); | ||
}); | ||
|
||
it('should be disabled when --no-openssl-legacy-provider is set', function () { | ||
expect(runLegacyProviderCheck(null, '--no-openssl-legacy-provider')).toBe(false); | ||
}); | ||
|
||
it('should be disabled when --no-openssl-legacy-provider is set after --openssl-legacy-provider', function () { | ||
expect( | ||
runLegacyProviderCheck(null, '--openssl-legacy-provider --no-openssl-legacy-provider') | ||
).toBe(false); | ||
}); | ||
}); | ||
|
||
describe('using exec arguments', function () { | ||
it('should be enabled when --openssl-legacy-provider is set', function () { | ||
expect(runLegacyProviderCheck('--openssl-legacy-provider')).toBe(true); | ||
}); | ||
|
||
it('should be enabled when --openssl-legacy-provider is set after --no-openssl-legacy-provider', function () { | ||
expect(runLegacyProviderCheck('--no-openssl-legacy-provider --openssl-legacy-provider')).toBe( | ||
true | ||
); | ||
}); | ||
|
||
it('should be disabled when --no-openssl-legacy-provider is set', function () { | ||
expect(runLegacyProviderCheck('--no-openssl-legacy-provider')).toBe(false); | ||
}); | ||
|
||
it('should be disabled when --no-openssl-legacy-provider is set after --openssl-legacy-provider', function () { | ||
expect(runLegacyProviderCheck('--openssl-legacy-provider --no-openssl-legacy-provider')).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", | ||
], | ||
|