【问题标题】:Code signed with self-signed certificate basic constraint error使用自签名证书基本约束错误签名的代码
【发布时间】:2021-05-06 13:19:36
【问题描述】:

我想摆脱 Publisher: Unknown UAC 消息,为此我正在尝试使用自签名证书签署我的 .exe(用于测试目的,直到我获得公共证书):

我使用以下命令生成了证书密钥:

.\openssl req -nodes -x509 -newkey rsa:4096 -sha256 -keyout key.pem -out crt.pem -subj "/CN=localhost" -addext "subjectAltName = DNS:localhost" -days 10000

然后创建.pfx:

.\openssl pkcs12 -inkey key.pem -in crt.pem -export -out MyCert.pfx

已将证书导入受信任的根授权机构:

之后我签署了我的代码文件:

signtool sign /f "MyCert.pfx" /p 1234 /fd sha256 /tr http://timestamp.comodoca.com?td=sha256 /td sha256 /as /v "CodeSignTest1.exe"

但是当我打开文件属性时,我看到以下错误:

如何解决这个问题?是否可以使用自签名证书进行代码签名?我在 Windows 10 上。

PS:如果我使用此命令 $cert = New-SelfSignedCertificate -DNSName "www.domain.com" -CertStoreLocation Cert:\CurrentUser\My -Type CodeSigningCert -Subject "Example Code Signing Certificate" 创建证书,它可以工作。但我想知道 openssl 语句有什么问题。

【问题讨论】:

    标签: openssl certificate


    【解决方案1】:

    缺少基本约束扩展。请参阅Is there anyway to specify basicConstraints for openssl cert via command line 获取配置文件或添加它的命令行参数。

    由于您不需要 CA 证书,您可能需要使用 -addext basicConstraints=critical,CA:FALSE,pathlen:0

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-07-31
      • 2012-08-01
      • 2015-06-06
      • 2014-02-03
      • 2014-01-18
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多