Search code examples
javascriptnode.jscertificatessl-certificate

Getting TLS Error in Node application API call


If I do a GET in Postman it succeeds but if I try a GET in my Node.js application I get this error:

{ 
  Error: unable to verify the first certificate
  at TLSSocket.<anonymous> (_tls_wrap.js:1103:38)
  at emitNone (events.js:106:13)
  at TLSSocket.emit (events.js:208:7)
  at TLSSocket._finishInit (_tls_wrap.js:637:8)
  at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:467:38)
    message: 'unable to verify the first certificate',
    code: 'NetworkingError',
    region: 'us-east',
    hostname: '1.1.1.1',
    retryable: true,
    time: 2018-05-09T09:54:26.736Z 
}

I'm using the same endpoint and credentials.

What could be causing this?


Solution

  • I added NODE_TLS_REJECT_UNAUTHORIZED=0 at the start of my command.