所选证书对编码签名无效
The selected certificate is not valid for coded signing
我有以下 Powershell 脚本来为 C# 应用程序创建新证书:
$expirationDate = [datetime]::Today.AddYears(5)
$thumb = (New-SelfSignedCertificate -CertStoreLocation cert:\localmachine\my -DnsName $env:USERDNSDOMAIN -KeyExportPolicy Exportable -Provider "Microsoft Enhanced RSA and AES Cryptographic Provider" -NotAfter $expirationDate).Thumbprint
$pwd = '123456'
$SSpwd = ConvertTo-SecureString -String $pwd -Force -AsPlainText
$destinationDirectory = "C:\Test\"
$filename = "mycert.pfx"
$pathAndFilename = $destinationDirectory + $filename
Export-PfxCertificate -cert "cert:\localmachine\my$thumb" -FilePath $pathAndFilename -Password $SSpwd
运行良好。然后在 Visual Studio 中,在应用程序的项目属性页面上,签名选项卡上,我单击 "Select from File" 并浏览到该文件,我得到:
The selected certificate is not valid for coded signing. Choose
another certicate file.
我做错了什么?
根据@ConnorLSW 评论添加信息。我现在有这个脚本:
$pwd = '123456'
$SSpwd = ConvertTo-SecureString -String $pwd -Force -AsPlainText
$destinationDirectory = "C:\Test\"
$filename = "mycert.pfx"
$pathAndFilename = $destinationDirectory + $filename
Import-PfxCertificate -cert "cert:\localmachine\my" -FilePath $pathAndFilename -Password $SSpwd
输出:
Directory: Microsoft.PowerShell.Security\Certificate::LocalMachine\my
Thumbprint Subject
AA1032E160156EC22D4447967A8B6401FF25E838 CN=AAAA.BBBB.CC.DDD
那里和 documentation 中都没有提到用法,我看也没有提到用法。我如何获得此信息?
您需要 运行 New-SelfSignedCertificate
和 -Type CodeSigningCert
才能获得可用于代码签名的证书。
是的,New-SelfSignedCertificate
的 Get-Help
页面超级没用。
[请注意,我无法看到您的屏幕截图,因为该图片主机在我的网络上被阻止了。]
我有以下 Powershell 脚本来为 C# 应用程序创建新证书:
$expirationDate = [datetime]::Today.AddYears(5)
$thumb = (New-SelfSignedCertificate -CertStoreLocation cert:\localmachine\my -DnsName $env:USERDNSDOMAIN -KeyExportPolicy Exportable -Provider "Microsoft Enhanced RSA and AES Cryptographic Provider" -NotAfter $expirationDate).Thumbprint
$pwd = '123456'
$SSpwd = ConvertTo-SecureString -String $pwd -Force -AsPlainText
$destinationDirectory = "C:\Test\"
$filename = "mycert.pfx"
$pathAndFilename = $destinationDirectory + $filename
Export-PfxCertificate -cert "cert:\localmachine\my$thumb" -FilePath $pathAndFilename -Password $SSpwd
运行良好。然后在 Visual Studio 中,在应用程序的项目属性页面上,签名选项卡上,我单击 "Select from File" 并浏览到该文件,我得到:
The selected certificate is not valid for coded signing. Choose another certicate file.
我做错了什么?
根据@ConnorLSW 评论添加信息。我现在有这个脚本:
$pwd = '123456'
$SSpwd = ConvertTo-SecureString -String $pwd -Force -AsPlainText
$destinationDirectory = "C:\Test\"
$filename = "mycert.pfx"
$pathAndFilename = $destinationDirectory + $filename
Import-PfxCertificate -cert "cert:\localmachine\my" -FilePath $pathAndFilename -Password $SSpwd
输出:
Directory: Microsoft.PowerShell.Security\Certificate::LocalMachine\my
Thumbprint Subject
AA1032E160156EC22D4447967A8B6401FF25E838 CN=AAAA.BBBB.CC.DDD
那里和 documentation 中都没有提到用法,我看也没有提到用法。我如何获得此信息?
您需要 运行 New-SelfSignedCertificate
和 -Type CodeSigningCert
才能获得可用于代码签名的证书。
是的,New-SelfSignedCertificate
的 Get-Help
页面超级没用。
[请注意,我无法看到您的屏幕截图,因为该图片主机在我的网络上被阻止了。]