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

Den*_*oli 5 node.js electron electron-builder

我正在构建一个 Electron 应用程序并使用 npm 包电子构建器为 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)
...
Run Code Online (Sandbox Code Playgroud)

然后我尝试设置环境变量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)
...
Run Code Online (Sandbox Code Playgroud)

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

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

Den*_*oli 1

不确定问题的根源是什么,但我可以通过将文件移至 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 上问题讨论的链接: https: //github.com/electron-userland/electron-builder/issues/291