I am trying to execute https request
from my node server side but it give me following error :-
Caught exception: Error: CERT_UNTRUSTED
If i execute http request
then it's working fine but for https
links its not working.
Here is my code:-
var request = require('request');
request('https://en.m.wikipedia.org/wiki/Astrid_Olofsdotter_of_Sweden', function (error, response, body) {
if (!error && response.statusCode == 200) {
console.log(body) // Show the HTML for the Google homepage.
}
})
Any Idea?
This could be down to a number of things, Ive run your code and its fine for me
node --version
v0.12.5
so I would look at
periodically root certificates are updated , i would suggest updating as it could possibly be that the cert used is newer than the root certificates in your distribution and is hence showing as untrusted
network - its possible that you are behind a proxy that does something unexpected with your requests
the target server , it could be returning something unexpected.
The most likely is 1, that you are using a version of nodejs that doesnt recognise the certificate provider of the site and therefore says that its untrusted.
I'd put 2 and 3 about the same level of likelyhood. if you are spidering wikipedia, its possible they've blocked you / pushed you to an error page where the certificate may not be valid.
Whilst you can , as the other posters have suggested, turn off verification, I would advise against it as a habit. And never do it in production environments.
The only time I break this rule is for self signed certificates on local machines.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With