I’m using openssl-nodejs package to use openssl commands to generate CSR and Private key.
We are successfully generating the CSR and Private key files with below code. However, it’s always returning the error response.
async function generateCsr(){
let subject = '';
let password = 'DummyPassword';
subject = `/CN=y1212.website.com/OU=Dp-PD/O=Dummy org/L=mars/C=DJ/[email protected]`;
openssl(
[
'req',
'-sha256',
'-newkey',
'rsa:2048',
'-keyout',
'y1212.website.com-privkey.pem',
'-out',
'y1212.website.com.csr',
'-subj',
`${subject}`,
'-passout',
`pass:${password}`
], function (err, buffer) {
if (err) console.log('OpenSSL error: ' + err); // RETURNS ERROR DESPITE OF GENERATING CORRECT FIELS
console.log("string", buffer.toString()); // THIS IS NULL
});
}
generateCsr();
Output:
OpenSSL process ends with code 0
OpenSSL error: Generating a 2048 bit RSA private key
writing new private key to 'openssl/y1212.website.com-privkey.pem'
Question: Why it is always returning the error despite of generating the correct CSR and Private keys. Due to this, we are unable to handle error handling. How can we resolve this issue?