Error: Install-Package Authenticode issuer in PowerShell module

Error: Install-Package Authenticode issuer in PowerShell module

我们已经建立了一个 TFS 包存储库来托管内部开发的 PS 5.1 模块。在发布之前,我们使用 GoDaddy 代码签名证书对这些 POSH 模块进行签名。一切正常,直到今天早上我们开始在

上出现下面提到的错误
Install-Module -Name DeploymentHelpers -RequiredVersion 0.2.0 -Repository 'CI' -Force

我确信应用程序开发方面或证书没有任何变化。

这是我们得到的错误:

PackageManagement\Install-Package : Authenticode issuer 'System.Object[]' of the new module 'DeploymentHelpers' with version '0.2.0' is not matching with the authenticode issuer 'System.Object[]' of the previously-installed module 'DeploymentHelpers' with version '0.2.0'. If you still want to install or update, use -SkipPublisherCheck parameter. At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet.0.0.1\PSModule.psm1:1772 char:21 + ... $null = PackageManagement\Install-Package @PSBoundParameters + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Package], Exception + FullyQualifiedErrorId : AuthenticodeIssuerMismatch,Validate-ModuleAuthenticodeSignature,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage

我在 Windows 2012 R2 和 TFS 2017.1

此外,这里是 CI 回购详细信息:

Register-PSRepository `
    -Name CI `
    -SourceLocation "http://tfs:8080/tfs/Projects/_packaging/CI/nuget/v2" `
    -PublishLocation 'http://tfs:8080/tfs/Projects/_packaging/CI/nuget/v2' `
    -PackageManagementProvider Nuget `
    -InstallationPolicy Trusted

有什么想法吗?

Authenticode issuer 'System.Object[]' of the new module 'DeploymentHelpers' with version '0.2.0' is not matching with the authenticode issuer 'System.Object[]' of the previously-installed module 'DeploymentHelpers' with version '0.2.0'.

这是 PowerShellGet v1.0.0.1 中存在的已知问题。您可以按照文件路径查看源验证脚本:C:\Program Files\WindowsPowerShell\Modules\PowerShellGet.0.0.1\PSModule.psm1

首先,请关注函数Get-AuthenticodePublisher。这是第一个用于获取和验证模块的 SignerCertificate 的函数。你可以分析它的脚本。用一句话表达这个逻辑就是它沿着证书链走。这意味着,现在,您已被 PowerShellGet 视为 "same" 发布者,因为您提供的签名证书与证书链中的签名证书相同正在检查中。

现在有3个方案可以供大家参考。

  • 第一个是添加错误消息中显示的参数: -SkipPublisherCheck。有了这个参数,它就可以主动 忽略 证书验证步骤。因此,错误将消失。
  • 第二种解决方案是修改文件 PSModule.psm1 添加 script Select-Object -First 1 进入函数 Get-AuthenticodePublisher。正如我之前提到的,款待 由相同的证书引起的。现在,使用 Select-Object 就可以了 拿起第一个。
  • 最后的解决办法是,你最好把PowerShellGet版本升级到latest版本,因为这个 PowerShellGet v2.1.4 中的逻辑问题已得到修复:Module publisher verification

注意:如果选择第三个,需要注意requirements最新的PowerShellGet版本: