NuGet 错误 NU3001

方案 1

Invalid password was provided for the certificate file 'certificate.pfx'. Provide a valid password using the '-CertificatePassword' option.

问题

向 NuGet 签名操作提供了受密码保护的证书文件。 但提供了无效密码或未提供密码。

解决方案

如果使用受密码保护的证书文件对 NuGet 包进行签名,请使用 -CertificatePassword 选项传递正确的密码。

方案 2

Certificate file 'certificate.pfx' not found. For a list of accepted ways to provide a certificate, visit https://docs.nuget.org/docs/reference/command-line-reference.

问题

已向 NuGet Sign 操作提供证书文件。 但磁盘上不存在该文件。

解决方案

请确保磁盘上存在用于对 NuGet 包进行签名的证书文件。

方案 3

Certificate file 'random_file.txt' is invalid. For a list of accepted ways to provide a certificate, visit https://docs.nuget.org/docs/reference/command-line-reference.

问题

向 NuGet Sign 操作提供了证书文件,但该文件不是有效证书文件。

解决方案

请确保用于对 NuGet 包进行签名的所有证书文件均为有效证书文件。

方案 4

Multiple certificates were found that meet all the given criteria. Use the '-CertificateFingerprint' option with the hash of the desired certificate.

问题

使用 -CertificateSubjectName 选项向 NuGet Sign 命令提供了建议的证书。 但发现多个证书与 Windows 证书存储中的证书使用者名称匹配。

解决方案

请将附带所需证书哈希的“-CertificateFingerprint”选项传递给 NuGet Sign 命令以对证书进行唯一标识。

方案 5

No certificates were found that meet all the given criteria. For a list of accepted ways to provide a certificate, visit https://docs.nuget.org/docs/reference/command-line-reference.

问题

使用 -CertificateSubjectName 选项向 NuGet Sign 命令提供了建议的证书。 但未找到与 Windows 证书存储中的证书使用者名称匹配的证书使用者名称。

解决方案

请务必传递正确的使用者名称筛选器,否则请将附带所需证书哈希的“-CertificateFingerprint”选项传递给 NuGet Sign 命令以对证书进行唯一标识。

方案 6

The following certificate cannot be used for package signing as the private key provider is unsupported:
  Subject Name: CN=Certificate Subject Name
  SHA1 hash: HASH
  SHA256 hash: HASH
  Issued by: Issuer Subject Name
  Valid from: 4/9/2016 5:00:00 PM to 4/14/2020 5:00:00 AM

问题

已将证书传递给 NuGet Sign 命令,但该命令具有不受支持的私钥提供程序。

解决方案

目前,由于框架限制,NuGet Sign 命令不支持 CNG 密钥私钥提供程序。 请将证书与 CAPI 私钥提供程序配合使用。

方案 7

The package already contains a signature. Remove the existing signature before adding a new signature.

问题

使用 NuGet Sign 命令对已具有包签名的包进行了签名。

解决方案

请确保对未签名的包进行签名。 如果包已签名,请使用 -Overwrite 选项覆盖现有签名。