【发布时间】:2020-02-28 12:14:22
【问题描述】:
我有一个使用 identityServer 4 的 .Net Core API,我正在尝试将 API 运行到 Docker Compose(Windows 容器)中,但由于以下异常而无法执行:
Unable to configure HTTPS endpoint. No server certificate was specified, and the default developer certificate could not be found or is out of date.
To generate a developer certificate run 'dotnet dev-certs https'. To trust the certificate (Windows and macOS only) run 'dotnet dev-certs https --trust'.
For more information on configuring HTTPS see https://go.microsoft.com/fwlink/?linkid=848054.
在谷歌上花了几个小时后,我发现了许多链接,其中首先安装证书,例如
dotnet dev-certs https --clean
dotnet dev-certs https --trust
**Docker - certificate not trusted**
1. Delete the C:\Users{USER}\AppData\Roaming\ASP.NET\Https folder.
2. Clean the solution. Delete the bin and obj folders.
3. Restart the Development tool. Visual Studio Code- 2019
在完成上述所有操作后面临同样的错误,我是不是在做错事。
这里是 dockerfile
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-nanoserver-1809 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
user ContainerAdministrator
FROM mcr.microsoft.com/dotnet/core/sdk:3.1-nanoserver-1809 AS build
WORKDIR /src
COPY ../Certificate/idsrv3test.pfx .
COPY ["Tests-Identity/Tests-Identity.csproj", "Tests-Identity/"]
RUN dotnet restore "Tests-Identity/Tests-Identity.csproj"
COPY . .
WORKDIR "/src/Tests-Identity"
RUN dotnet build "Tests-Identity.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "Tests-Identity.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Tests-Identity.dll"]
这里是 docker-compose.override.yml
version: '3.4'
services:
tests-identity:
environment:
- ASPNETCORE_ENVIRONMENT=Development
- ASPNETCORE_URLS=https://+:443;http://+:80
ports:
- "5000:80"
- "5001:443"
volumes:
- ${APPDATA}/Microsoft/UserSecrets:C:\Users\ContainerUser\AppData\Roaming\Microsoft\UserSecrets:ro
- ${APPDATA}/ASP.NET/Https:C:\Users\ContainerUser\AppData\Roaming\ASP.NET\Https:ro
【问题讨论】:
标签: docker .net-core docker-compose dockerfile x509certificate