【问题标题】:Checksum mismatch after code sign Electron Builder / Updater代码签名 Electron Builder / Updater 后校验和不匹配
【发布时间】:2018-03-06 13:12:34
【问题描述】:

在构建过程中运行适用于 Windows / NSIS 的 electron-builder 后,我们的开发运营团队设置了一个构建脚本,该脚本运行以在部署之前对 exe 进行代码签名。到达服务器后,electron-updater 因 sha512 校验和不匹配而失败(该错误发生在安装期间,在完全下载后)。我还尝试从服务器上拉下 exe 文件并从 Visual Studio CMD 运行一个 codesign util,然后重新上传。自动更新程序也会失败并出现同样的错误。

难道不能在生成后对 exe 进行签名,并且仍然允许自动更新程序工作吗?

签名:

signtool.exe sign /tr http://timestamp.digicert.com /td sha256 /fd sha256 /sha1 value "path"

日志:

Error: sha512 checksum mismatch, expected [value], got [different value]

package.json 中的配置:

"build": {
    "appId": "com.stripped.stripped.stripped",
    "directories": {
        "output": "dist-exe",
        "app": "dist"
    },
    "win": {
        "target": "nsis",
        "icon": "dist/assets/favicon/favicon-256x256.ico",
        "verifyUpdateCodeSignature": false,
        "publish": {
            "provider": "generic",
            "url": "##{ElecronAppUpdaterLocation}##"
        }
    },
    "nsis": {
        "artifactName": "Setup_${version}.${ext}",
        "installerIcon": "dist/assets/favicon/favicon-256x256.ico",
        "installerHeaderIcon": "dist/assets/favicon/favicon-256x256.ico"
    }
}

【问题讨论】:

    标签: electron code-signing electron-builder


    【解决方案1】:

    如果有人还在寻找手动生成电子校验和,您可以使用这里提到的脚本https://github.com/electron-userland/electron-builder/issues/3913#issuecomment-504698845

    我已经对其进行了测试,它运行良好,Electron 能够使用手动生成的校验和将应用更新到版本。

    const path = require('path');
    const fs = require('fs');
    const crypto = require('crypto');
    
    const YOUR_FILE_PATH = '';  //  POPULATE THIS
    
    function hashFile(file, algorithm = 'sha512', encoding = 'base64', options) {
      return new Promise((resolve, reject) => {
        const hash = crypto.createHash(algorithm);
        hash.on('error', reject).setEncoding(encoding);
        fs.createReadStream(
          file,
          Object.assign({}, options, {
            highWaterMark: 1024 * 1024,
            /* better to use more memory but hash faster */
          })
        )
          .on('error', reject)
          .on('end', () => {
            hash.end();
            console.log('hash done');
            console.log(hash.read());
            resolve(hash.read());
          })
          .pipe(
            hash,
            {
              end: false,
            }
          );
      });
    }
    
    const installerPath = path.resolve(
      __dirname,
      YOUR_FILE_PATH
    );
    
    hashFile(installerPath);
    

    【讨论】:

    • 嗨,我不知道如何使用这个代码 sn-p。将此代码 sn-p 放在哪里,以及如何/何时运行它?
    【解决方案2】:

    根据response to the issue on electron-builder in GH,生成后不允许签名,不幸的是,这改变了我们的构建过程。

    【讨论】:

      猜你喜欢
      • 2016-07-18
      • 2014-07-25
      • 1970-01-01
      • 1970-01-01
      • 2021-11-09
      • 2019-06-08
      • 1970-01-01
      • 2017-04-06
      • 2011-03-10
      相关资源
      最近更新 更多