I have a Node.js library that makes https.request
(https://nodejs.org/api/https.html) calls to external sources.
In some cases, the user of the library may be behind a proxy. Due to configuration (or misconfiguration?) of the proxy, users behind the proxy may experience issues with SSL certificates. In this case, in order to make https requests in Node, you need to set the https.request
option: rejectUnauthorized
to be false
. (on a related note, these proxies typically require npm --strict-ssl=false
as well)
How can I setup a test that simulates being behind a proxy that rejects signed certificates so that I can ensure that my library will work properly for those behind proxies such as these?
I'm using mocha
and/or chai
as the testing library and nock
to simulate external sources that are being called.