Using NodeJS to connect to backend

Not applicable

Hi,

I am trying to use NodeJS to connect to the backend over https. Using the request module to connect

var options = { url: 'https:xxxx.com', method:'POST', cert: fs.readFileSync(__dirname + '/xxxx.cer', 'utf-8'), key: fs.readFileSync(__dirname + '/xxxx.key', 'utf-8'), agent: false, rejectUnauthorized: false, auth:{ 'password':'xxx.' } };

https.request(options,callback); but I get the exception Error: org.bouncycastle.openssl.PasswordException: Password is null, but a password is required at crypto.js:112 at tls.js:1185 at createConnection (https.js:79) Can you guide me on what is wrong Thanks
0 1 236
1 REPLY 1

Yes, this error is telling you that there is a password on the key, and you haven't specified one.

I think you need something like this:

var options = {
      url: 'https:xxxx.com',
      method:'POST',
      cert: fs.readFileSync(__dirname + '/xxxx.cer', 'utf-8'),
      key: fs.readFileSync(__dirname + '/xxxx.key', 'utf-8'),
      passphrase: 'secret123',
      agent: false,
      rejectUnauthorized: false,
      auth:{ 'password':'xxx.' }
    };