superagent icon indicating copy to clipboard operation
superagent copied to clipboard

ability to set rejectUnauthorized to false

Open andrewrk opened this issue 13 years ago • 13 comments

as of node v0.10, if you try to access an SSL endpoint which is not in node's default CA list, an error will be thrown. There should be a way to set an option so that rejectUnauthorized is set to false.

See http://nodejs.org/docs/latest/api/https.html#https_https_request_options_callback

andrewrk avatar Mar 12 '13 05:03 andrewrk

This might be a better option:

https://github.com/visionmedia/superagent/issues/197

RGBboy avatar Mar 29 '13 00:03 RGBboy

I think both options should be exposed..

andrewrk avatar Mar 29 '13 03:03 andrewrk

Agree with @superjoe30; the ability to set the rejectUnauthorized option would be preferred in some circumstances (such as mine). My use of superagent is against a local developer's machine with self-signed certificates, and the self-signed cert would be different per-host. It's far easier to just set rejectUnauthorized to false, than to have to get the proper cert for the machine and add it to the trusted CA list.

dpolivy avatar Apr 29 '13 22:04 dpolivy

@dpolivy as a workaround, you can do this:

process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";

andrewrk avatar Apr 30 '13 03:04 andrewrk

@superjoe30 That works great, thanks for the tip!

dpolivy avatar May 03 '13 17:05 dpolivy

Yes, Thanks for the tips!

thaihau avatar May 13 '13 12:05 thaihau

Closing issue since there is an ENV var workaround. I don't think we have specific node options.

defunctzombie avatar Mar 22 '15 21:03 defunctzombie

An example of where this would be useful and the environment variable workaround is with webhooks.

I'm setting up webhooks in my app, and I'm copying the github API. They have a configuration flag called 'insecure_ssl'.

bryanlarsen avatar Nov 24 '15 16:11 bryanlarsen

@defunctzombie

process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0" This sets SSL off for all http requests in the process. Shutting off all together would be drastic in production use.

Do you know how to set it off for one particular request. Anyone??

yuyudhan avatar May 11 '16 19:05 yuyudhan

I don't recommend disabling HTTPS security. If you can't get a trusted certificate, then try creating your own CA and set it as trusted in superagent using .ca().

http://stackoverflow.com/a/24749608/27009

kornelski avatar May 11 '16 20:05 kornelski

@pornel We have system in production that communicates with many external systems on production and test basises (we integrating with people, other people integriate and test integration with us). Recently maintainers of one of this external systems forgot to update certificate and now part of important for us API do not work. While they requesting new cert (2-3 weeks) we set temporary rejectUnauthorized: false for only requests to this API with checking while it is updated to revert option to true.

But some tests with requests to this API written with chai-http which uses superagent and while i can suppress errors for native nodejs request with rejectUnauthorized, for chai-http i can`t.

Setting process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0" kills security of many other requests even if i will be reverted in in response callback.

What to do? Change testing framework because of this small but important in real life option?

rusekr avatar Oct 15 '17 17:10 rusekr

Semi-serious, but you could put the broken-SSL endpoint behind CloudFlare CDN. They don't care about enforcing end-to-end security, but do enough to make superagent, etc. to believe it's secure.

I feel your frustration, but you should be pressuring the broken-SSL-2-week-cert people to fix their security, rather than expecting superagent to weaken its. These days proper TLS certificates are free, can be obtained in minutes, and renewed entirely automatically. I'm not relenting, so that all people failing to make their TLS work are under pressure to fix their TLS rather than disable it so they can keep their broken implementations and outdated processes.

kornelski avatar Oct 15 '17 22:10 kornelski

Big companies have big bureaucracy. Frustration because maintainer of lib used in popular testing(!) framework rejects to have basic nodejs simple configurability in its wrapper and i cant simply fork it because i need to fork chai-http too. It's even already pull requests. No need to do anything. It's like some linux distro which disallows users to have simple passwords because it's insecure but creators of that distro cant think about how wide it can be used for example for tests in virtual environment or as demo short-ttl containers.

rusekr avatar Oct 16 '17 15:10 rusekr