Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

https certificate error when proxying to server with self-signed certificate #214

Closed
gerkirill opened this issue Dec 2, 2015 · 3 comments · Fixed by #688
Closed

https certificate error when proxying to server with self-signed certificate #214

gerkirill opened this issue Dec 2, 2015 · 3 comments · Fixed by #688

Comments

@gerkirill
Copy link

In development we often deal with dev. servers which have self-signed SSL certificate. If I use --proxy option pointing to such a server - I get following error upon proxy attempt:

node_modules/http-proxy/lib/http-proxy/index.js:119
    throw err;
          ^
Error: SELF_SIGNED_CERT_IN_CHAIN
    at SecurePair.<anonymous> (tls.js:1381:32)
    at SecurePair.emit (events.js:92:17)
    at SecurePair.maybeInitFinished (tls.js:980:10)
    at CleartextStream.read [as _read] (tls.js:472:13)
    at CleartextStream.Readable.read (_stream_readable.js:341:10)
    at EncryptedStream.write [as _write] (tls.js:369:25)
    at doWrite (_stream_writable.js:226:10)
    at writeOrBuffer (_stream_writable.js:216:5)
    at EncryptedStream.Writable.write (_stream_writable.js:183:11)
    at write (_stream_readable.js:602:24)

This will not happen if you pass secure: false option to httpProxy.createProxyServer. You can do it by default or enable with some option. I can compose a pull request if you like.

@vukasin-nikodijevic
Copy link

This is sooooo needed fix - especially if I'm using this for proxying in development where I have multiple backends and all of them with self signed cert.
What will be good is to have support for more then proxy backend - same as proxyPass directive in Apache.

@jhagege
Copy link

jhagege commented Jan 16, 2017

Any news on this ?

@javiercbk
Copy link

javiercbk commented Mar 30, 2017

In my mac I did the following hack (Because I have no time to make a PR)

  1. Install npm install -g http-server
  2. Edited the global http-server.js located in (my mac) /usr/local/lib/node_modules/http-server/lib/http-server.js. I installed node via homebrew
  3. At line 105 add the secure: false option like this: var proxy = httpProxy.createProxyServer({secure: false});
  4. Submit a PR with this change (optional)

Caveats: This is a developer's solution to a developer's problem. You should not make this change in a production environment or something like that. I personally would set this as a cli config parameter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment