diff --git a/aspnetcore/security/docker-https.md b/aspnetcore/security/docker-https.md index 68c58bbba3..7300404cf9 100644 --- a/aspnetcore/security/docker-https.md +++ b/aspnetcore/security/docker-https.md @@ -22,7 +22,7 @@ This sample requires [Docker 17.06](https://docs.docker.com/release-notes/docker ## Prerequisites -The [.NET Core 2.2 SDK](https://dotnet.microsoft.com/download) or later is required for some of the instructions in this document. +The current [.NET SDK](https://dotnet.microsoft.com/download). ## Certificates @@ -52,22 +52,22 @@ Use the following instructions for your operating system configuration. Generate certificate and configure local machine: ```dotnetcli -dotnet dev-certs https -ep %USERPROFILE%\.aspnet\https\aspnetapp.pfx -p +dotnet dev-certs https -ep %USERPROFILE%\.aspnet\https\aspnetapp.pfx -p dotnet dev-certs https --trust ``` -In the preceding commands, replace `` with a password. +In the preceding commands, replace `` with a password. Run the container image with ASP.NET Core configured for HTTPS in a command shell: ```console docker pull mcr.microsoft.com/dotnet/samples:aspnetapp -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="password" -e ASPNETCORE_Kestrel__Certificates__Default__Path=/https/aspnetapp.pfx -v %USERPROFILE%\.aspnet\https:/https/ mcr.microsoft.com/dotnet/samples:aspnetapp +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="" -e ASPNETCORE_Kestrel__Certificates__Default__Path=/https/aspnetapp.pfx -v %USERPROFILE%\.aspnet\https:/https/ mcr.microsoft.com/dotnet/samples:aspnetapp ``` -When using [PowerShell](/powershell/scripting/overview), replace `%USERPROFILE%` with `$env:USERPROFILE`. +In the preceding code, replace `` with the password. The password must match the password used for the certificate. -The password must match the password used for the certificate. +When using [PowerShell](/powershell/scripting/overview), replace `%USERPROFILE%` with `$env:USERPROFILE`. Note: The certificate in this case must be a `.pfx` file. Utilizing a `.crt` or `.key` file with or without the password isn't supported with the sample container. For example, when specifying a `.crt` file, the container may return error messages such as 'The server mode SSL must use a certificate with the associated private key.'. When using [WSL](/windows/wsl/about), validate the mount path to ensure that the certificate loads correctly. @@ -76,41 +76,43 @@ Note: The certificate in this case must be a `.pfx` file. Utilizing a `.crt` or Generate certificate and configure local machine: ```dotnetcli -dotnet dev-certs https -ep ${HOME}/.aspnet/https/aspnetapp.pfx -p { password here } +dotnet dev-certs https -ep ${HOME}/.aspnet/https/aspnetapp.pfx -p dotnet dev-certs https --trust ``` `dotnet dev-certs https --trust` is only supported on macOS and Windows. You need to trust certs on Linux in the way that is supported by your distribution. It is likely that you need to trust the certificate in your browser. -In the preceding commands, replace `{ password here }` with a password. +In the preceding commands, replace `` with a password. Run the container image with ASP.NET Core configured for HTTPS: ```console docker pull mcr.microsoft.com/dotnet/samples:aspnetapp -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="password" -e ASPNETCORE_Kestrel__Certificates__Default__Path=/https/aspnetapp.pfx -v ${HOME}/.aspnet/https:/https/ mcr.microsoft.com/dotnet/samples:aspnetapp +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="" -e ASPNETCORE_Kestrel__Certificates__Default__Path=/https/aspnetapp.pfx -v ${HOME}/.aspnet/https:/https/ mcr.microsoft.com/dotnet/samples:aspnetapp ``` -The password must match the password used for the certificate. +In the preceding code, replace `` with the password. The password must match the password used for the certificate. ### Windows using Windows containers Generate certificate and configure local machine: ```dotnetcli -dotnet dev-certs https -ep %USERPROFILE%\.aspnet\https\aspnetapp.pfx -p { password here } +dotnet dev-certs https -ep %USERPROFILE%\.aspnet\https\aspnetapp.pfx -p dotnet dev-certs https --trust ``` -In the preceding commands, replace `{ password here }` with a password. When using [PowerShell](/powershell/scripting/overview), replace `%USERPROFILE%` with `$env:USERPROFILE`. +In the preceding commands, replace `` with a password. When using [PowerShell](/powershell/scripting/overview), replace `%USERPROFILE%` with `$env:USERPROFILE`. Run the container image with ASP.NET Core configured for HTTPS: ```console docker pull mcr.microsoft.com/dotnet/samples:aspnetapp -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="password" -e ASPNETCORE_Kestrel__Certificates__Default__Path=\https\aspnetapp.pfx -v %USERPROFILE%\.aspnet\https:C:\https\ --user ContainerAdministrator mcr.microsoft.com/dotnet/samples:aspnetapp +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="" -e ASPNETCORE_Kestrel__Certificates__Default__Path=c:\https\aspnetapp.pfx -v %USERPROFILE%\.aspnet\https:C:\https\ --user ContainerAdministrator mcr.microsoft.com/dotnet/samples:aspnetapp ``` +***NOTE:*** `` is a placeholder for the Kestrel certificates default password. + The password must match the password used for the certificate. When using [PowerShell](/powershell/scripting/overview), replace `%USERPROFILE%` with `$env:USERPROFILE`. ## Developing ASP.NET Core Applications with Docker over HTTPS @@ -119,4 +121,5 @@ See [Developing ASP.NET Core Applications with Docker over HTTPS](https://github ## See also +* [Developing ASP.NET Core Applications with Docker over HTTPS](https://github.com/dotnet/dotnet-docker/blob/main/samples/run-aspnetcore-https-development.md) * [`dotnet dev-certs`](/dotnet/core/tools/dotnet-dev-certs)