Electron Builder 代码签名下载证书错误

Electron Builder Code Signing Download Certificate Error

我正在构建一个 Electron 应用程序并使用 npm 包 electron-builder 为 Windows 构建应用程序和安装程序。我正在尝试使用 CSC_LINKCSC_KEY_PASSWORD 环境变量对应用程序进行签名,如下所述:https://github.com/electron-userland/electron-builder#travis-appveyor-and-other-ci-servers

第一次尝试错误和堆栈跟踪是:

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)
...

然后我尝试设置环境变量 NODE_TLS_REJECT_UNAUTHORIZED=0,现在得到一个不同的错误:

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)
...

在 electron-builder 的 httpRequest.ts 中调用的特定行似乎只是在使用 Node 的 https 模块:https.request(...) https://github.com/electron-userland/electron-builder/blob/master/src/httpRequest.ts#L28

这让我相信 Windows 机器或证书有问题。我 运行 在 Windows 10,节点 5.9.0.

最好将问题直接提交给 https://github.com/electron-userland/electron-builder/issues 以获得维护者的答复。我是当前活跃的维护者,不检查 SO,因此,您不太可能很快得到答案;)

如果问题对您来说仍然存在,请提交问题:)

不确定问题的根源是什么,但是通过将文件移动到 Dropbox,我能够使一切正常工作。我仍然必须设置 NODE_TLS_REJECT_UNAUTHORIZED=0 并且 CSC_LINK 需要不带引号设置:

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

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

关于 electron-builder GitHub 的问题讨论的 link 可以在这里找到:https://github.com/electron-userland/electron-builder/issues/291