ability to set rejectUnauthorized to false
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
This might be a better option:
https://github.com/visionmedia/superagent/issues/197
I think both options should be exposed..
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 as a workaround, you can do this:
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
@superjoe30 That works great, thanks for the tip!
Yes, Thanks for the tips!
Closing issue since there is an ENV var workaround. I don't think we have specific node options.
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'.
@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??
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
@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?
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.
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.