title: Electron Builder Code Signing Download Certificate Error
body: <p>I'm building an Electron app and using the npm package electron-builder to build the app and installer for Windows. I'm trying to use the <code>CSC_LINK</code> and <code>CSC_KEY_PASSWORD</code> environment variables to sign the app as described here: <a href="https://github.com/electron-userland/electron-builder#travis-appveyor-and-other-ci-servers" rel="nofollow">https://github.com/electron-userland/electron-builder#travis-appveyor-and-other-ci-servers</a></p>
  
  <p>On first try the error and stack trace is:</p>
  
  <pre><code>Unhandled rejection Error: unable to verify the first certificate
  at Error (native)
  at TLSSocket.&lt;anonymous&gt; (_tls_wrap.js:1065:38)
  at emitNone (events.js:80:13)
  at TLSSocket.emit (events.js:179:7)
  at TLSSocket._init.ssl.onclienthello.ssl.oncertcb.TLSSocket._finishInit (_tls_wrap.js:593:8)
  at TLSWrap.ssl.onclienthello.ssl.oncertcb.ssl.onnewsession.ssl.onhandshakedone (_tls_wrap.js:425:38)
  From previous event:
  at Object.downloadCertificate (C:\projects\presentation\Electron\node_modules\electron-builder\src\codeSign.ts:97:18)
  ...
  </code></pre>
  
  <p>I then tried setting the environment variable <code>NODE_TLS_REJECT_UNAUTHORIZED=0</code> and now get a different error:</p>
  
  <pre><code>Unhandled rejection Error: Request error, status 400: Bad Request
  at ClientRequest.&lt;anonymous&gt; (C:\projects\presentation\Electron\node_modules\electron-builder\src\httpRequest.ts:36:16)
  ...
  </code></pre>
  
  <p>The particular line that is being called in electron-builder's <code>httpRequest.ts</code> appears to just be using Node's https module: <code>https.request(...)</code> <a href="https://github.com/electron-userland/electron-builder/blob/master/src/httpRequest.ts#L28" rel="nofollow">https://github.com/electron-userland/electron-builder/blob/master/src/httpRequest.ts#L28</a></p>
  
  <p>This leads me to believe there is something up with the Windows machine or certificates. I'm running this on Windows 10, node 5.9.0.</p>