title: Node HTTP-Proxy to HTTPS server with client certificate
body: <p>Our servers rely on client certificates to validate access. Right now neither Electron nor NW.JS seem to support client certificates yet, which prevents us from creating an application that can connect to our server. </p>
  
  <p>After doing some research, it seems like it should be possible to use <strong>node-http-proxy</strong> to setup a proxy server that all of the communications go through. It looks like it's possible to introduce the client certificate through this method, essentially:</p>
  
  <p>Client Request -> Proxy Server (adds client certificate) -> Server (response) -> Proxy Server -> Client</p>
  
  <p>I'm not entirely sure if this is possible or not, but that's what I'm aiming for. This is the code I have so far:</p>
  
  <pre><code>var cert = fs.readFileSync ("./cert.p12");
  var proxy = httpProxy.createProxyServer ({
      target: {
          host: "devserver",
          protocol: "https:",
          port: 443,
          pfx: cert,
          passphrase: "certificatepassword"   
      },
      secure: false,
      changeOrigin: true,
      xfwd: true,
      //agent: https.globalAgent
      agent: false
  }).listen (8080);
  </code></pre>
  
  <p>PFX is a loaded in .p12 file. When I set this as the proxy server in Firefox I get "Secure Connection Failed" when attempting to reach our development server. I've tried a bunch of different methods with no better results and I'm not sure how to continue from this point...</p>