Skip to content

Commit

Permalink
Update src/setup_node_env/openssl_legacy_provider/openssl_legacy_prov…
Browse files Browse the repository at this point in the history
…ider_enabled.js

Co-authored-by: Thomas Watson <[email protected]>
  • Loading branch information
jbudz and watson authored Aug 30, 2023
1 parent 9a20dd9 commit f9c03a5
Showing 1 changed file with 3 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,8 @@
* 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;
const crypto = require('crypto');

var cliOpenSSLLegacyProvider = checkOpenSSLLegacyProvider(execOptions);
var envOpenSSLLegacyProvider = checkOpenSSLLegacyProvider(nodeOptions);
// The blowfish cipher is only available when node is running with the --openssl-legacy-provider flag
module.exports = crypto.getCiphers().includes('blowfish');

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;
}

0 comments on commit f9c03a5

Please sign in to comment.