VS-构建容器化应用DockerFile && 启用 SSL 的 ASP.NET Core 应用
作者:互联网
参考
VS-构建容器化应用DockerFile && 启用 SSL 的 ASP.NET Core 应用
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
实践完整步骤
-
%APPDATA%\ASP.NET\Https
默认证书位置 -
DockerDemo
项目名称,必须要证书名称一致 -
crypticpassword
SSL证书密码
在window宿主机设置证书
DockerDemo\DockerDemo.csproj
项目相对路径C:\Users\JinXi\AppData\Roaming\ASP.NET\Https
可以使用相对路径
移除已经存在的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证书
/mnt/c/Users/JinXi/AppData/Roaming/ASP.NET/Https
为wsl下的绝对路径
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