我在服务器端有一个Asp.Net Core 3 Api,在客户端有Angular 8。我正在尝试配置Dockerfile,以构建我的api的docker映像,并使用CircleCI将其部署到Heroku,但似乎无法为https正确配置它。
我尝试使用'dotnet dev-certs https -v -ep my-app-root \ cert_aspnetcore.pfx -p some-password'命令将证书生成到我的项目中,并使用以下命令更新Program.cs中的CreateHostBuilder函数以下:
webBuilder.UseKestrel(options =>
{
options.Listen(IPAddress.Any, 443, listenOptions =>
{
listenOptions.UseHttps("cert_aspnetcore.pfx", "some-password");
});
});
但是它在Heroku视图日志中给出了以下错误:
Unhandled exception. Interop+Crypto+OpenSslCryptographicException: error:2006D080:BIO routines:BIO_new_file:no such file
这是我的Dockerfile,它很好地部署了api,试图为https支持添加一些配置:
FROM mcr.microsoft.com/dotnet/core/aspnet:3.0-buster-slim AS base
WORKDIR /app
FROM mcr.microsoft.com/dotnet/core/sdk:3.0-buster AS build
WORKDIR /src
COPY ["ResourceAuthServer.csproj", "./"]
RUN dotnet restore "./ResourceAuthServer.csproj"
COPY . .
WORKDIR "/src/."
RUN dotnet build "ResourceAuthServer.csproj" -c Release -o /app
FROM build AS publish
RUN dotnet publish "ResourceAuthServer.csproj" -c Release -o /app
FROM base AS final
WORKDIR /app
COPY --from=publish /app .
CMD ASPNETCORE_URLS=http://*:$PORT dotnet ResourceAuthServer.dll
我如何正确配置Dockerfile和api(如果需要)以便在https上运行它?