在 .net 5.0 sdk 容器中 build 项目时执行 dotnet restore 出现下面的错误
Package 'Microsoft.Extensions.Configuration.Binder 3.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
Dockefile 中对应的指令如下
FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
WORKDIR /src
COPY *.sln *.props NuGet.config ./
COPY ./*/*.csproj ./
RUN for file in $(ls *.csproj); do mkdir -p ./${file%.*}/ && mv $file ./${file%.*}/; done
RUN dotnet restore
COPY . .
RUN dotnet build -c Release --no-restore
请问如何解决这个问题?
在 https://github.com/NuGet/Home/issues/10491 的评论中找到了临时解决方法:
在 Dockerfile 中 FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
之后添加下面的指令
ADD http://ftp.us.debian.org/debian/pool/main/c/ca-certificates/ca-certificates_20210119_all.deb .
RUN dpkg -i ca-certificates_20210119_all.deb
RUN apt-get update && apt-get install -y ca-certificates && update-ca-certificates && rm -rf /var/lib/apt/lists/*
后来我们采用的最简单的解决方法是把镜像tag中的5.0
改为5.0-focal
,focal对应的是ubuntu 20.04
改为 focal 后,软件源替换为国内镜像的命令需要改为
RUN sed -i s@/archive.ubuntu.com/@/mirrors.aliyun.com/@g /etc/apt/sources.list
同问。。。程序都还没跑起来,别的也不敢再跑了。。。
是不是得等那边大佬更新签名证书。。。
看了看都是System和Microsoft下的包出问题
FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
改为:
FROM mcr.microsoft.com/dotnet/sdk:5.0.102-ca-patch-buster-slim AS build
官方出公告了 NuGet restore failing on .NET 5 for Debian-based OSes
– dudu 4年前github 相关 issue:NuGet restore failing on .NET 5 for Debian-based OSes (CA trust changed)
– dudu 4年前stackoverflow 上的相关问题:The author primary signature's timestamp found a chain building issue: UntrustedRoot: self signed certificate in certificate chain
– dudu 4年前