aacerox / node-rest-client

REST API client from node.js
MIT License
377 stars 132 forks source link

self signed certificate error when calling https end point #181

Open gurupraveen-avvaru opened 6 years ago

gurupraveen-avvaru commented 6 years ago

Hi Team,

I am calling https end point using node-rest-client, I am getting below error.

events.js:137 throw er; // Unhandled 'error' event ^

Error: self signed certificate in certificate chain at TLSSocket.onConnectSecure (_tls_wrap.js:1041:34) at TLSSocket.emit (events.js:160:13) at TLSSocket._finishInit (_tls_wrap.js:638:8)

Please let me know how to fix this issue.

--Guru

ranupoju0126 commented 6 years ago

I am also having the same issue, there is temporary solution to add rejectUnauthorized as false, which is not safe,

I did find the options in documentation, but still same error occurs image

pranavtheway commented 6 years ago

where exactly this configuration needs to be edited?

ranupoju0126 commented 6 years ago

@gurupraveen-avvaru Hope you have that self signed certificate .crt file convert that .crt file to .pem file using the following command openssl x509 -inform DER -outform PEM -in server.crt -out server.pem

then use give the path of that .pem file in options var options = { user:xxxxxx password: xxxxxx, connection: { ca:fs.readFileSync('/Users/xxxx/WebstormProjects/project-Master/server/server.pem') }, }

Done! This will work for sure

pranavtheway commented 6 years ago

Hey @ranupoju0126

Where can i get the .crt file and what configuration file we are talking about here?

teja12687 commented 6 years ago

@pranavtheway .crt file you should get from the team who has done secure connections to the domain(https).

I am not sure about what configuration file you are talking about

Th only configuration I know is which I posted a screenshot in my previous comment.

drizzyemtk54 commented 6 years ago

i got this error using nodemailer and gmail as my demo account.. any solutions?