http-party / node-http-proxy

A full-featured http proxy for node.js
https://github.com/http-party/node-http-proxy
Other
13.88k stars 1.96k forks source link

Proxy with client certificates #826

Open javierpavon2000 opened 9 years ago

javierpavon2000 commented 9 years ago

I'm trying to perform a proxy to an url that needs a client certificate. The context is:

Now, I've defined an object like that

var objConf = { target: 'https://aaa.com/webservice:4278',
  secure: false,
  headers: { host: 'scytl-sessmgm.cloudapp.net:4278' },
  ssl:
   { key: '-----BEGIN RSA PRIVATE KEY----- ..... -----END RSA PRIVATE KEY-----',
     cert: '-----BEGIN CERTIFICATE----- ... -----END CERTIFICATE-----' 
    }
}

and the, I create the proxy

var proxy = httpProxy.createProxyServer(objConf);

But, it doesn't work, the request always returns a 403 status code.

Am I doing something wrong? Any help? Thanks

kjlaw89 commented 9 years ago

I'm curious if there's a way to do this too. I opened a Stack Overflow question on it the other day: http://stackoverflow.com/questions/30331618/node-http-proxy-to-https-server-with-client-certificate

briangreenery commented 9 years ago

For sure it's possible for http-proxy to use a client certificate. I just answered that Stack Overflow question, although I used the key, cert, and ca options instead of the pfx option. I think the example will still work if you use the pfx option instead.

Here's a working demo: https://gist.github.com/briangreenery/e2f03c0058e3589a9acf