【问题标题】:Nuget: This package is signed but not by a trusted signerNuget:此包已签名,但不是由受信任的签名者签名
【发布时间】:2020-09-24 08:38:21
【问题描述】:

我需要你的帮助。

我的配置:

  • Visual Studio 社区 2019
  • Windows 10 x64 1909

我想使用 nuget 下载软件包,但我总是收到这个 f**ked 错误(见标题)。

我的解决方案文件夹的结构:

  • D:\MySln\
    • nuget.config
    • nuget_packages
    • HelloWorld\
    • 你好孙\

我的 nuget.config 文件:https://docs.microsoft.com/en-us/nuget/reference/nuget-config-file

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <config>
    <!--
        Used to specify the default location to expand packages.
        See: nuget.exe help install
        See: nuget.exe help update

        In this example, %PACKAGEHOME% is an environment variable.
        This syntax works on Windows/Mac/Linux
    -->
       <add key="repositoryPath" value=".\nuget_packages" />

    <!--
        Used to specify default source for the push command.
        See: nuget.exe help push
    -->
        <!--
        <add key="defaultPushSource" value="https://MyRepo/ES/api/v2/package" />
    -->

    <!-- Proxy settings -->
        <add key="http_proxy" value="host" />
        <add key="http_proxy.user" value="username" />
        <add key="http_proxy.password" value="encrypted_password" />
    </config>

    <packageRestore>
    <!-- Allow NuGet to download missing packages -->
        <add key="enabled" value="True" />

    <!-- Automatically check for missing packages during build in Visual Studio -->
        <add key="automatic" value="True" />
    </packageRestore>

<!--
    Used to specify the default Sources for list, install and update.
    See: nuget.exe help list
    See: nuget.exe help install
    See: nuget.exe help update
-->
    <packageSources>
        <add key="NuGet official package source" value="https://api.nuget.org/v3/index.json" />
        <!--
        <add key="MyRepo - ES" value="https://MyRepo/ES/nuget" />
        -->
    </packageSources>

<!-- Used to store credentials -->
    <packageSourceCredentials />

<!-- Used to disable package sources  -->
    <disabledPackageSources />

<!--
    Used to specify default API key associated with sources.
    See: nuget.exe help setApiKey
    See: nuget.exe help push
    See: nuget.exe help mirror
-->
    <apikeys>
        <add key="https://MyRepo/ES/api/v2/package" value="encrypted_api_key" />
   </apikeys>

<!--
    Used to specify trusted signers to allow during signature verification.
    See: nuget.exe help trusted-signers
-->
    <trustedSigners>
        <author name="microsoft">
            <certificate fingerprint="3F9001EA83C560D712C24CF213C3D312CB3BFF51EE89435D3430BD06B5D0EECE" hashAlgorithm="SHA256" allowUntrustedRoot="false" />
        </author>
        <repository name="nuget.org" serviceIndex="https://api.nuget.org/v3/index.json">
            <certificate fingerprint="0E5F38F57DC1BCC806D8494F4F90FBCEDD988B46760709CBEEC6F4219AA6157D" hashAlgorithm="SHA256" allowUntrustedRoot="false" />
            <owners>microsoft;aspnet;nuget</owners>
        </repository>
    </trustedSigners>
</configuration>

无论是使用 nuget cli 还是使用 Visual Studio Nuget 包管理器,我总是会遇到该错误。

感谢您的帮助!

【问题讨论】:

    标签: nuget visual-studio-2019


    【解决方案1】:

    您的 nuget.config 末尾有 trustedSigners 部分,表示仅信任:

    • 由 Microsoft 的签名证书签名的包。没有其他软件包作者受信任。
    • 仅信任来自 nuget.org 的包,不信任其他来源
      • 来自 nuget.org,仅信任 microsoft、aspnet 和 nuget 帐户拥有的软件包

    任何其他包(例如 newtonsoft.json、xunit、nunit 等)都不会被信任,因为它不符合此条件。

    如果您不是在必须非常严格地管理“安全供应链”的环境中工作,您可以从 nuget.config 中删除整个 trustedSigners 部分。

    根据您想要实现的目标(为什么首先启用受信任的签名者),lock files 可能是一种不太严格的方法来降低 CI 机器使用与您在自己的 devbox 上使用的不同包的风险.

    有关受信任签名者的更多文档:https://docs.microsoft.com/en-us/nuget/consume-packages/installing-signed-packages

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-06-23
      • 2012-04-02
      • 1970-01-01
      • 2015-11-02
      • 2018-09-28
      • 2012-04-23
      • 2016-07-07
      • 1970-01-01
      相关资源
      最近更新 更多