-
Notifications
You must be signed in to change notification settings - Fork 8.6k
[node] Enable openssl legacy provider #163190
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
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
e6de936
[node] Enable openssl legacy provider
jbudz 0746710
Merge branch 'main' into node-openssl-legacy-provider
jbudz 61f528a
Merge branch 'main' into node-openssl-legacy-provider
jbudz 9a20dd9
Update docs/user/production-considerations/production.asciidoc
jbudz f9c03a5
Update src/setup_node_env/openssl_legacy_provider/openssl_legacy_prov…
jbudz 8494644
Merge branch 'main' into node-openssl-legacy-provider
jbudz 56e0a6f
fix function
jbudz 633d772
tmp remove test file, needs to be replaced by exec
jbudz 8ab1e77
re-add tests
jbudz c1ed440
remove log
jbudz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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", | ||
| ], | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@elastic/kibana-core any thoughts on where I can put this check to hook into the core logger? This is currently pre-startup, where we have similar node checks such as validating node.js's version, not running as root etc.
The difference is this doesn't need to prevent startup, and the default experience with this log looks out of place.