如何为 macos 应用程序包和 linux 可执行文件签署数字签名

How to signing digital signature for macos app bundle and linux executable

我有一个 java swing 应用程序和构建可执行文件,适用于三个平台 Window (exe)、macOS(.app) 和 linux(.sh)。我还有一个 .p12 文件,需要为三个平台可执行文件签名。

我已通过 osslsigncode 在 windows 上签署了 exe 文件,并且可以在 exe 文件的属性中检查数字签名选项卡。

现在,我面临的问题是我不知道如何将 .p12 文件签名为 macOS 可执行文件 (.app) 和 linux 可执行文件 (.sh)。

我也很困惑,我们可以将 .p12 文件签名到 macOS 并在 linux 构建服务器上 Linux 可执行文件,如 windows 数字签名吗?

我已经使用 linux 构建服务器为三个平台构建可执行文件

我也尝试使用 openssl 命令作为:

openssl rsautl -sign -inkey MyFile.p12 -passin pass:mypass > /path/to/my/sh/file

但出现错误:无法加载私钥

有什么建议吗?

谢谢大家。

编码愉快..

您可以使用此命令从 .p12 (pfx) 中提取私钥

openssl pkcs12 -in file.p12 -nocerts -out key.pem

然后你可以签署你的文件

openssl rsautl -sign -inkey key.pem -in yourfile -out sigfile

并用

openssl pkeyutl -verify -pubin -inkey pubkey.pem -sigfile sigfile -in yourfile

验证

但您应该签署/验证校验和而不是使用实际文件,因此最好使用

sha512sum yourfile | openssl rsautl -sign -inkey yourkey -out sigfile
sha512sum yourfile | openssl pkeyutl -verify -pubin -inkey pubkey.pem -sigfile sigfile