繁体   English   中英

NuGet 恢复在 Docker 容器内停止工作

[英]NuGet restore stopped working inside Docker Container

当我在构建时尝试将dotnet restore作为DockerfileRUN指令运行时,出现以下错误:

/src/Anonymized.Tests/Anonymized.Tests.csproj : error NU3028: Package 'Microsoft.Win32.SystemEvents 5.0.0' from source 'https://api.nuget.org/v3/index.json': The author primary signature's timestamp found a chain building issue: UntrustedRoot: self signed certificate in certificate chain [/src/Anonymized.sln]
/src/Anonymized.Tests/Anonymized.Tests.csproj : error NU3037: Package 'Microsoft.Win32.SystemEvents 5.0.0' from source 'https://api.nuget.org/v3/index.json': The author primary signature validity period has expired. [/src/Anonymized.sln]

我所有的 NuGet 包都会发生这种情况。

如果我在容器外运行它,它工作得很好。

我正在使用图像mcr.microsoft.com/dotnet/sdk:5.0 难道是我运行它的 Docker 图像以某种方式过期的证书?

它一直工作到几个小时前。

编辑:不确定它是否是重要信息,但这都是从 Linux 中的 GitHub Actions 运行的。

编辑:

解决方案1:

如 github 所述,如果您的 Dockerfile 看起来与此类似: FROM mcr.microsoft.com/dotnet/sdk:5.0将其更改为

  • FROM mcr.microsoft.com/dotnet/sdk:5.0-alpine ,或
  • FROM mcr.microsoft.com/dotnet/sdk:5.0-focal

解决方案2:

在运行恢复之前将此添加到您的 Dockerfile 中:

RUN curl -o /usr/local/share/ca-certificates/verisign.crt -SsL https://crt.sh/?d=1039083 && update-ca-certificates

出于安全原因,您可能需要下载并验证证书并将其保存到您的存储库中。 这是验证包时间戳所必需的证书,它默认包含在 alpine 和 focus 中,但在 debian 中缺失。

解决方案3:

等待微软解决问题。 They're tracking it on github and Nuget has set it's status to degraded until the problem is solved: https://status.nuget.org/

原答案:

据我所知,Docker 在这种情况下是正确的。 Download any NuGet package manually, ie: https://www.nuget.org/api/v2/package/System.ComponentModel.Annotations/5.0.0 Open the file and look for the.signature.p7s file and open it with the默认程序。 它向我显示,微软的证书在当地时间今天下午 1 点过期。

证书

我不知道为什么这对于 docker 之外的工具来说不是问题。 我知道有一种方法可以完全禁用这里解释的 NuGet 验证以及有关有效期的更多信息: https: //docs.microsoft.com/en-us/nuget/reference/errors-and-warnings/nu3028 https:/ /docs.microsoft.com/en-us/nuget/reference/errors-and-warnings/nu3037

我真的不想完全禁用检查。 可悲的是我也不知道在这种情况下如何进行

目前,该问题似乎与 Debian 图像有关。

改用基于 Ubuntu 的图像:

FROM mcr.microsoft.com/dotnet/sdk:5.0-focal 

关注https://github.com/NuGet/Home/issues/10491以获取更新。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM