DennyFerra DennyFerra - 4 months ago 22
Node.js Question

Electron Builder Code Signing Download Certificate Error

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

CSC_LINK
and
CSC_KEY_PASSWORD
environment variables to sign the app as described here: https://github.com/electron-userland/electron-builder#travis-appveyor-and-other-ci-servers

On first try the error and stack trace is:

Unhandled rejection Error: unable to verify the first certificate
at Error (native)
at TLSSocket.<anonymous> (_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)
...


I then tried setting the environment variable
NODE_TLS_REJECT_UNAUTHORIZED=0
and now get a different error:

Unhandled rejection Error: Request error, status 400: Bad Request
at ClientRequest.<anonymous> (C:\projects\presentation\Electron\node_modules\electron-builder\src\httpRequest.ts:36:16)
...


The particular line that is being called in electron-builder's
httpRequest.ts
appears to just be using Node's https module:
https.request(...)
https://github.com/electron-userland/electron-builder/blob/master/src/httpRequest.ts#L28

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.

Answer

Not certain what the root of the issue was however I was able to get everything to work by moving the file to Dropbox. I still had to set NODE_TLS_REJECT_UNAUTHORIZED=0 and CSC_LINK needed to be set without quotes:

Success: SET CSC_LINK=https://www.dropbox.com/s/path/to/file.p12?dl=1

Failed: SET CSC_LINK="https://www.dropbox.com/s/path/to/file.p12?dl=1"

A link to the issue discussion on electron-builder GitHub can be found here: https://github.com/electron-userland/electron-builder/issues/291