编程语言
首页 > 编程语言> > VS-构建容器化应用DockerFile && 启用 SSL 的 ASP.NET Core 应用

VS-构建容器化应用DockerFile && 启用 SSL 的 ASP.NET Core 应用

作者:互联网

参考

VS-构建容器化应用DockerFile && 启用 SSL 的 ASP.NET Core 应用

SSL证书

docker-https

设置ssl证书

docker 映射证书命令

docker run --rm -it -p 8000:80 -p 8001:443 -e ASPNETCORE_URLS="https://+;http://+" -e ASPNETCORE_HTTPS_PORT=8001 -e ASPNETCORE_Kestrel__Certificates__Default__Password="crypticpassword" -e ASPNETCORE_Kestrel__Certificates__Default__Path=/https/DockerDemo.pfx -v /mnt/c/Users/JinXi/AppData/Roaming/ASP.NET/Https:/https/ dockerdemo:new

实践完整步骤

在window宿主机设置证书
移除已经存在的user-secrets
dotnet user-secrets remove "Kestrel:Certificates:Development:Password" -p DockerDemo\DockerDemo.csproj
清除证书
dotnet dev-certs https --clean
重新生成证书
dotnet dev-certs https -ep C:\Users\JinXi\AppData\Roaming\ASP.NET\Https\DockerDemo.pfx -p crypticpassword
dotnet dev-certs https --trust
dotnet user-secrets -p DockerDemo\DockerDemo.csproj set "Kestrel:Certificates:Development:Password" "crypticpassword"
运行容器命令,映射数据卷SSL证书
docker run --rm -it -p 8000:80 -p 8001:443 -e ASPNETCORE_URLS="https://+;http://+" -e ASPNETCORE_HTTPS_PORT=8001 -e ASPNETCORE_Kestrel__Certificates__Default__Password="crypticpassword" -e ASPNETCORE_Kestrel__Certificates__Default__Path=/https/DockerDemo.pfx -v /mnt/c/Users/JinXi/AppData/Roaming/ASP.NET/Https:/https/ dockerdemo:new

标签:__,Core,ASP,ASPNETCORE,SSL,DockerDemo,https,NET
来源: https://www.cnblogs.com/vsnb/p/16127431.html