totaljs / framework

Node.js framework
http://www.totaljs.com
Other
4.36k stars 450 forks source link

How to ignore U.request() causing self signed certificate in certificate chain error. #774

Closed DPain closed 3 years ago

DPain commented 3 years ago

Hi, I'm testing total.js locally can noticed that my U.request() method has been causing self signed certificate error. I thought setting NODE_TLS_REJECT_UNAUTHORIZED = 0 would fix the issue, but it doesn't.

I've been using axios as a temporary workaround by setting httpsAgent with a rejectUnauthorized: false flag.

Right now, I've just set the following before starting my app and it seems to work. https.globalAgent.options.rejectUnauthorized = false;

Is there a way to set the httpAgent for individual U.request() methods?

Thanks, in advance!

petersirka commented 3 years ago

Hi, NODE_TLS_REJECT_UNAUTHORIZED must work, try to add allow_ssc_validation : false into the /config file.

I recommend to use Total.js v4:

var opt = {};
opt.url = 'https://yourlink.com';
opt.insecure = true;
opt.callback = function(err, response) {

    // response.headers {Object}
    // response.body {String/Object} a response body
    // response.status {Number} status code
    // response.host {String} resolved host name (opt.resolve = true returns IP address)
    // response.cookies {Object} response cookies (nullable)

};

REQUEST(opt);
DPain commented 3 years ago

Thanks! I'll try that out.

DPain commented 3 years ago

Yup that fixed the issue! Thank you so much :)