Skip to content

Commit f0c9041

Browse files
Update run-aspnetcore-https-development.md with <CREDENTIAL_PLACEHOLDER> (#4143)
1 parent b1baba3 commit f0c9041

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

samples/run-aspnetcore-https-development.md

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
ASP.NET Core uses [HTTPS by default](https://docs.microsoft.com/aspnet/core/security/enforcing-ssl). [HTTPS](https://en.wikipedia.org/wiki/HTTPS) relies on [certificates](https://en.wikipedia.org/wiki/Public_key_certificate) for trust, identity, and encryption.
44

5-
This document demonstrates how to develop ASP.NET Core applications with HTTPS in Docker containers. It is recommended to try the [ASP.NET Core Docker Sample](README.md) first, which is simpler because the container only exposes HTTP. This more basic tutorial will help you validate that you have the sample working correctly, before adding the complication of certificates.
5+
This document demonstrates how to develop ASP.NET Core applications with HTTPS in Docker containers. It's recommended to try the [ASP.NET Core Docker Sample](README.md) first, which is simpler because the container only exposes HTTP. This more basic tutorial will help you validate that you have the sample working correctly, before adding the complication of certificates.
66

77
See [Hosting ASP.NET Core Images with Docker over HTTPS](host-aspnetcore-https.md) for production scenarios.
88

@@ -24,11 +24,11 @@ You can also [download the repository as a zip](https://github.com/dotnet/dotnet
2424

2525
ASP.NET Core uses [self-signed development certificates](https://en.wikipedia.org/wiki/Self-signed_certificate) for development. Self-signed certificates are easy and free to create.
2626

27-
The instructions volume mount certificates into containers. You can add certificates into container images with a `COPY` command in a Dockerfile. This approach is not recommended. It makes it harder to use the same image for testing with dev certificates and hosting with production certificates. There is also a significant risk of certificate disclosure if certificates are made part of container images.
27+
The instructions volume mount certificates into containers. You can add certificates into container images with a `COPY` command in a Dockerfile. This approach isn't recommended. It makes it harder to use the same image for testing with dev certificates and hosting with production certificates. There's also a significant risk of certificate disclosure if certificates are made part of container images.
2828

2929
## Application Secrets
3030

31-
These instructions assume that your project is configured for [application secrets](https://docs.microsoft.com/aspnet/core/security/app-secrets). The primary requirement is a [UserSecretsId](https://github.com/dotnet/dotnet-docker/blob/main/samples/aspnetapp/aspnetapp/aspnetapp.csproj#L5) element in your project file. If you are using the ASP.NET Core sample in this repo, you don't need to do anything. It is already correctly configured. If you are using your own project file, add an `UserSecretsId` element.
31+
These instructions assume that your project is configured for [application secrets](https://docs.microsoft.com/aspnet/core/security/app-secrets). The primary requirement is a [UserSecretsId](https://github.com/dotnet/dotnet-docker/blob/main/samples/aspnetapp/aspnetapp/aspnetapp.csproj#L5) element in your project file. If you're using the ASP.NET Core sample in this repo, you don't need to do anything. It's already correctly configured. If you're using your own project file, add an `UserSecretsId` element.
3232

3333
You can add the element manually or use Visual Studio to do it for you. The following image demonstrates the experience in Visual Studio.
3434

@@ -46,7 +46,7 @@ Use the following instructions, for your operating system configuration. The com
4646
4747
![Developer Tools -- Delete cookie](https://user-images.githubusercontent.com/2608468/40246148-875fee5a-5a7c-11e8-9728-7da89a491014.png)
4848

49-
Further, if you're loading SSL certificates and trimming assemblies as part of the publish, you'll also need to update the project file for the sample. Please see details for how you can [support SSL certificates](https://docs.microsoft.com/en-us/dotnet/core/deploying/trim-self-contained#support-for-ssl-certificates).
49+
Further, if you're loading SSL certificates and trimming assemblies as part of the publish, you'll also need to update the project file for the sample. See details for how you can [support SSL certificates](https://docs.microsoft.com/en-us/dotnet/core/deploying/trim-self-contained#support-for-ssl-certificates).
5050

5151
### Windows using Linux containers
5252

@@ -61,20 +61,20 @@ cd samples\aspnetapp
6161
Generate cert and configure local machine:
6262

6363
```console
64-
dotnet dev-certs https -ep $env:USERPROFILE\.aspnet\https\aspnetapp.pfx -p crypticpassword
64+
dotnet dev-certs https -ep $env:USERPROFILE\.aspnet\https\aspnetapp.pfx -p <CREDENTIAL_PLACEHOLDER>
6565
dotnet dev-certs https --trust
6666
```
6767

6868
> Note: The certificate name, in this case *aspnetapp*.pfx must match the project assembly name.
6969
70-
> Note: `crypticpassword` is used as a stand-in for a password of your own choosing.
70+
> Note: `<CREDENTIAL_PLACEHOLDER>` is used as a stand-in for a password of your own choosing.
7171
7272
> Note: If console returns "A valid HTTPS certificate is already present.", a trusted certificate already exists in your store. It can be exported using MMC Console.
7373
7474
Configure application secrets, for the certificate:
7575

7676
```console
77-
dotnet user-secrets -p aspnetapp\aspnetapp.csproj set "Kestrel:Certificates:Development:Password" "crypticpassword"
77+
dotnet user-secrets -p aspnetapp\aspnetapp.csproj set "Kestrel:Certificates:Development:Password" "<CREDENTIAL_PLACEHOLDER>"
7878
```
7979

8080
> Note: The password must match the password used for the certificate.
@@ -102,18 +102,18 @@ cd samples\aspnetapp
102102
Generate cert and configure local machine:
103103

104104
```console
105-
dotnet dev-certs https -ep ${HOME}/.aspnet/https/aspnetapp.pfx -p crypticpassword
105+
dotnet dev-certs https -ep ${HOME}/.aspnet/https/aspnetapp.pfx -p <CREDENTIAL_PLACEHOLDER>
106106
dotnet dev-certs https --trust
107107
```
108108

109109
> Note: The certificate name, in this case *aspnetapp*.pfx must match the project assembly name.
110110
111-
> Note: `crypticpassword` is used as a stand-in for a password of your own choosing.
111+
> Note: `<CREDENTIAL_PLACEHOLDER>` is used as a stand-in for a password of your own choosing.
112112
113113
Configure application secrets, for the certificate:
114114

115115
```console
116-
dotnet user-secrets -p aspnetapp/aspnetapp.csproj set "Kestrel:Certificates:Development:Password" "crypticpassword"
116+
dotnet user-secrets -p aspnetapp/aspnetapp.csproj set "Kestrel:Certificates:Development:Password" "<CREDENTIAL_PLACEHOLDER>"
117117
```
118118

119119
> Note: The password must match the password used for the certificate.
@@ -141,19 +141,19 @@ cd samples\aspnetapp
141141
Generate cert and configure local machine:
142142

143143
```console
144-
dotnet dev-certs https -ep ${HOME}/.aspnet/https/aspnetapp.pfx -p crypticpassword
144+
dotnet dev-certs https -ep ${HOME}/.aspnet/https/aspnetapp.pfx -p <CREDENTIAL_PLACEHOLDER>
145145
```
146146

147147
> Note: `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 distro. It is likely that you need to trust the certificate in your browser.
148148
149149
> Note: The certificate name, in this case *aspnetapp*.pfx must match the project assembly name.
150150
151-
> Note: `crypticpassword` is used as a stand-in for a password of your own choosing.
151+
> Note: `<CREDENTIAL_PLACEHOLDER>` is used as a stand-in for a password of your own choosing.
152152
153153
Configure application secrets, for the certificate:
154154

155155
```console
156-
dotnet user-secrets -p aspnetapp/aspnetapp.csproj set "Kestrel:Certificates:Development:Password" "crypticpassword"
156+
dotnet user-secrets -p aspnetapp/aspnetapp.csproj set "Kestrel:Certificates:Development:Password" "<CREDENTIAL_PLACEHOLDER>"
157157
```
158158

159159
Build a container image:
@@ -165,7 +165,7 @@ docker build --pull -t aspnetapp .
165165
Run the container image with ASP.NET Core configured for HTTPS:
166166

167167
```console
168-
docker run --rm -it -p 8000:80 -p 8001:443 -e ASPNETCORE_URLS="https://+;http://+" -e ASPNETCORE_HTTPS_PORT=8001 -e ASPNETCORE_ENVIRONMENT=Development -e ASPNETCORE_Kestrel__Certificates__Development__Password="crypticpassword" -v ${HOME}/.microsoft/usersecrets/:/root/.microsoft/usersecrets -v ${HOME}/.aspnet/https:/root/.aspnet/https/ aspnetapp
168+
docker run --rm -it -p 8000:80 -p 8001:443 -e ASPNETCORE_URLS="https://+;http://+" -e ASPNETCORE_HTTPS_PORT=8001 -e ASPNETCORE_ENVIRONMENT=Development -e ASPNETCORE_Kestrel__Certificates__Development__Password="<CREDENTIAL_PLACEHOLDER>" -v ${HOME}/.microsoft/usersecrets/:/root/.microsoft/usersecrets -v ${HOME}/.aspnet/https:/root/.aspnet/https/ aspnetapp
169169
```
170170

171171
After the application starts, navigate to `http://localhost:8000` in your web browser.
@@ -183,20 +183,20 @@ cd samples\aspnetapp
183183
Generate cert and configure local machine:
184184

185185
```console
186-
dotnet dev-certs https -ep $env:USERPROFILE\.aspnet\https\aspnetapp.pfx -p crypticpassword
186+
dotnet dev-certs https -ep $env:USERPROFILE\.aspnet\https\aspnetapp.pfx -p <CREDENTIAL_PLACEHOLDER>
187187
dotnet dev-certs https --trust
188188
```
189189

190190
> Note: The certificate name, in this case *aspnetapp*.pfx must match the project assembly name.
191191
192-
> Note: `crypticpassword` is used as a stand-in for a password of your own choosing.
192+
> Note: `<CREDENTIAL_PLACEHOLDER>` is used as a stand-in for a password of your own choosing.
193193
194194
> Note: If console returns "A valid HTTPS certificate is already present.", a trusted certificate already exists in your store. It can be exported using MMC Console.
195195
196196
Configure application secrets, for the certificate:
197197

198198
```console
199-
dotnet user-secrets -p aspnetapp\aspnetapp.csproj set "Kestrel:Certificates:Development:Password" "crypticpassword"
199+
dotnet user-secrets -p aspnetapp\aspnetapp.csproj set "Kestrel:Certificates:Development:Password" "<CREDENTIAL_PLACEHOLDER>"
200200
```
201201

202202
> Note: The password must match the password used for the certificate.
@@ -216,3 +216,4 @@ docker run --rm -it -p 8000:80 -p 8001:443 -e ASPNETCORE_URLS="https://+;http://
216216
After the application starts, navigate to `http://localhost:8000` in your web browser.
217217

218218
> In the case of using https, be sure to check the certificate you're using is trusted on the host. You can start with navigating to https://localhost:8001 in the browser. If you're looking to test https with a domain name (e.g. https://contoso.com:8001), the certificate would also need the appropiate Subject Alternative Name included, and the DNS settings on the host would need to be updated. In the case of using the generated dev certificate, the trusted certificate will be issued from localhost and will not have the SAN added.
219+

0 commit comments

Comments
 (0)