Linux 代码签名
本指南提供了有关 Linux 软件包代码签名的信息。虽然在 Linux 上部署你的应用不要求进行工件签名,但它可用于增加对已部署应用的信任。对二进制文件进行签名可以让终端用户验证这些文件是真实的,且未被其他不信任的实体修改。
🌐 This guide provides information on code signing for Linux packages. While artifact signing is not required for your application to be deployed on Linux, it can be used to increase trust into your deployed application. Signing the binaries allows your end user to verify that these are genuine and have not been modified by another untrusted entity.
🌐 Signing for AppImages
AppImage 可以使用 gpg 或 gpg2 进行签名。
🌐 The AppImage can be signed using either gpg or gpg2.
🌐 Prerequisites
必须准备一个用于签名的密钥。可以使用以下命令生成一个新的密钥:
🌐 A key for signing must be prepared. A new one can be generated using:
gpg2 --full-gen-key请参考 gpg 或 gpg2 文档以获取更多信息。你应特别注意将你的私钥和公钥备份到安全的位置。
🌐 Please refer to the gpg or gpg2 documentation for additional information. You should take additional care to back up your private and public keys in a secure location.
🌐 Signing
你可以通过设置以下环境变量将签名嵌入 AppImage:
🌐 You can embed a signature in the AppImage by setting the following environment variables:
- 签名:设置为
1以签署 AppImage。 - SIGN_KEY:可选变量,用于使用特定的 GPG 密钥 ID 进行签名。
- APPIMAGETOOL_SIGN_PASSPHRASE:签名密钥密码。如果未设置,gpg 会显示一个对话框以便你输入。你在 CI/CD 平台上构建时必须设置此项。
- APPIMAGETOOL_FORCE_SIGN:默认情况下,即使签名失败也会生成 AppImage。要在出现错误时退出,你可以将此变量设置为
1。
你可以通过运行以下命令显示嵌入在 AppImage 中的签名:
🌐 You can display the signature embedded in the AppImage by running the following command:
./src-tauri/target/release/bundle/appimage/$APPNAME_$VERSION_amd64.AppImage --appimage-signature请注意,你需要根据你的配置将 $APPNAME 和 $VERSION 值更改为正确的值。
🌐 Note that you need to change the $APPNAME and $VERSION values with the correct ones based on your configuration.
🌐 Validate the signature
AppImage 验证工具可以从 这里 下载。请选择一个 validate-$PLATFORM.AppImage 文件。
🌐 The AppImage validate tool can be downloaded from here.
Select one of the validate-$PLATFORM.AppImage files.
运行以下命令以验证签名:
🌐 Run the following command to validate the signature:
chmod +x validate-$PLATFORM.AppImage./validate-$PLATFORM.AppImage $TAURI_OUTPUT.AppImage如果签名有效,则输出将是:
🌐 If the signature is valid, the output will be:
Validation result: validation successfulSignatures found with key fingerprints: $KEY_ID====================Validator report:Signature checked for key with fingerprint $KEY_ID:Validation successfulTauri 中文网 - 粤ICP备13048890号
Nodejs.cn 旗下网站