11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ciconst common = require('../common'); 31cb0ef41Sopenharmony_ciif (!common.hasCrypto) { common.skip('missing crypto'); } 41cb0ef41Sopenharmony_ciconst assert = require('assert'); 51cb0ef41Sopenharmony_ciconst { generateKeyPair } = require('crypto'); 61cb0ef41Sopenharmony_ci 71cb0ef41Sopenharmony_ciif (common.isWindows) { 81cb0ef41Sopenharmony_ci // Remove this conditional once the libuv change is in Node.js. 91cb0ef41Sopenharmony_ci common.skip('crashing due to https://github.com/libuv/libuv/pull/2983'); 101cb0ef41Sopenharmony_ci} 111cb0ef41Sopenharmony_ci 121cb0ef41Sopenharmony_ci// Regression test for a race condition: process.exit() might lead to OpenSSL 131cb0ef41Sopenharmony_ci// cleaning up state from the exit() call via calling its destructor, but 141cb0ef41Sopenharmony_ci// running OpenSSL operations on another thread might lead to them attempting 151cb0ef41Sopenharmony_ci// to initialize OpenSSL, leading to a crash. 161cb0ef41Sopenharmony_ci// This test crashed consistently on x64 Linux on Node v14.9.0. 171cb0ef41Sopenharmony_ci 181cb0ef41Sopenharmony_cigenerateKeyPair('rsa', { 191cb0ef41Sopenharmony_ci modulusLength: 2048, 201cb0ef41Sopenharmony_ci privateKeyEncoding: { 211cb0ef41Sopenharmony_ci type: 'pkcs1', 221cb0ef41Sopenharmony_ci format: 'pem' 231cb0ef41Sopenharmony_ci } 241cb0ef41Sopenharmony_ci}, (err/* , publicKey, privateKey */) => { 251cb0ef41Sopenharmony_ci assert.ifError(err); 261cb0ef41Sopenharmony_ci}); 271cb0ef41Sopenharmony_ci 281cb0ef41Sopenharmony_cisetTimeout(() => process.exit(), common.platformTimeout(10)); 29