node-ssllabs
node-ssllabs copied to clipboard
Proxy-Agent breaks requests it shouldn't
For some reason, the include of node-ssllabs breaks requests it's not involved with at all. Seems it's adding a self signed certificate somewhere and using that?
The error is: (node:22827) UnhandledPromiseRejectionWarning: RequestError: self signed certificate
Here's a super simple example that reliably reproduces the error on my machine
npm i got node-ssllabs
const got = require('got');
const ssllabs = require('node-ssllabs');
(() => {
got('https://www.example.com')
.then((response) => {
console.log(response);
})
})();
I've verified this, and it's the include of Proxy-Agent here https://github.com/keithws/node-ssllabs/blob/master/lib/ssllabs.js#L18 that add's the behaviour.
If I comment that out, everything works as expected
Please report which version of node-ssllabs you are using. The latest version, 2.1.0, released about 7 months ago, stopped using a global proxy setting and instead uses per request setting.
Assuming you are using the latest, then it might be that the "proxy-agent" library needs to be updated. If you can, try updating proxy-agent to to the latest release and see if that fixes your issue.
I'm on node-ssllabs 2.1.0 and that's installing the latest on the 3.X branch of proxy-agent. Tried updating to 4.X and getting the same issue.
Breaks:
const got = require('got');
const ssllabs = require('node-ssllabs');
got('https://www.example.com')
.then((response) => {
console.log(response);
});
Works:
const got = require('got');
const ProxyAgent = require('proxy-agent');
got('https://www.example.com')
.then((response) => {
console.log(response);
});
I have a similar issue : UnhandledPromiseRejectionWarning: RequestError: connect ECONNREFUSED 127.0.0.1:443
Not the same error message, but the same root issue : node-ssllabs
package.json:
{
"name": "test-ssllabs",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "node index.js"
},
"dependencies": {
"got": "^11.8.0",
"node-ssllabs": "^2.1.0",
"proxy-agent": "^4.0.0"
}
}
ìndex.js`:
// FAIL
const got = require('got');
const ssllabs = require('node-ssllabs');
got('https://www.example.com').then((response) => {
console.log(response);
});
// WORKS
const got = require('got');
const ProxyAgent = require('proxy-agent');
got('https://www.example.com').then((response) => {
console.log(response);
});
I don't understand what is so different between code above and https://github.com/keithws/node-ssllabs/blob/master/lib/ssllabs.js#L18 🤔 Can't find the way to fixes this and submit a PR
Even more strange for me... I try to reproduce the error, without success
Works:
index.js:
const got = require('got');
const ssllabs = require('./node-ssllabs');
got('https://www.example.com').then((response) => {
console.log(response);
});
node-ssllabs.js:
module.exports = require('./lib/ssllabs');
lib/ssllabs.js: https://github.com/keithws/node-ssllabs/blob/master/lib/ssllabs.js
Failed:
index.js
const got = require('got');
const ssllabs = require('node-ssllabs');
got('https://www.example.com').then((response) => {
console.log(response);
});
Maybe something strange with require(...) and dependencies injection ? 🤔
Thank you @loic-moriame for testing this as well. I want to fix this, but I have not had much time and the root cause of the issue is not clear. I appreciate all the help trying to find the root cause.