You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: aspnetcore/includes/trustCertVSC.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@
4
4
dotnet dev-certs https --trust
5
5
```
6
6
7
-
The preceding command requires .NET 9.0 or higher on Linux. For Linux on .NET 8 and earlier, see your Linux distribution's documentation for trusting a certificate.
7
+
The preceding command doesn't work on Linux. See your Linux distribution's documentation for trusting a certificate.
8
8
9
9
The preceding command displays the following dialog, provided the certificate was not previously trusted:
On Linux, `dotnet dev-certs https --trust`requires .NET 9 and later. For Linux on .NET 8 and earlier, see your Linux distribution's documentation for trusting a certificate.
102
+
`dotnet dev-certs https --trust`is only supported on macOS and Windows. You need to trust certificates on Linux in the way that is supported by your distribution. It is likely that you need to trust the certificate in your browser.
103
103
104
104
In the preceding commands, replace `$CREDENTIAL_PLACEHOLDER$` with a password.
On Linux, `dotnet dev-certs https --trust` requires .NET 9 and later. For Linux on .NET 8 and earlier, see your Linux distribution's documentation for trusting a certificate.
83
+
`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.
84
+
84
85
In the preceding commands, replace `<CREDENTIAL_PLACEHOLDER>` with a password.
85
86
86
87
Run the container image with ASP.NET Core configured for HTTPS:
## Trust the ASP.NET Core HTTPS development certificate
202
+
## Trust the ASP.NET Core HTTPS development certificate on Windows and macOS
203
+
204
+
For the Firefox browser, see the next section.
203
205
204
206
The .NET Core SDK includes an HTTPS development certificate. The certificate is installed as part of the first-run experience. For example, `dotnet --info` produces a variation of the following output:
> Do not create a development certificate in an environment that will be redistributed, such as a container image or virtual machine. Doing so can lead to spoofing and elevation of privilege. To help prevent this, set the `DOTNET_GENERATE_ASPNET_CERTIFICATE` environment variable to `false` prior to calling the .NET CLI for the first time. This will skip the automatic generation of the ASP.NET Core development certificate during the CLI's first-run experience.
229
231
230
-
## How to set up a developer certificate for Docker
232
+
<aname="trust-ff"></a>
231
233
232
-
See [this GitHub issue](https://github.com/dotnet/AspNetCore.Docs/issues/6199).
234
+
### Trust the HTTPS certificate with Firefox to prevent SEC_ERROR_INADEQUATE_KEY_USAGE error
233
235
234
-
## Linux-specific considerations
236
+
The Firefox browser uses its own certificate store, and therefore doesn't trust the [IIS Express](/iis/extensions/introduction-to-iis-express/iis-express-overview) or [Kestrel](xref:fundamentals/servers/kestrel) developer certificates.
235
237
236
-
Linux distros differ substantially in how they mark certificates as trusted. While `dotnet dev-certs` is expected to be broadly applicable it is only officially supported on Ubuntu and Fedora and specifically aims to ensure trust in Firefox and Chromium-based browsers (Edge, Chrome, and Chromium).
238
+
There are two approaches to trusting the HTTPS certificate with Firefox, create a policy file or configure with the FireFox browser. Configuring with the browser creates the policy file, so the two approaches are equivalent.
237
239
238
-
###Dependencies
240
+
#### Create a policy file to trust HTTPS certificate with Firefox
239
241
240
-
To establish OpenSSL trust, the `openssl` tool must be on the path.
242
+
Create a policy file (`policies.json`) at:
241
243
242
-
To establish browser trust (e.g. in Edge or Firefox), the `certutil` tool must be on the path.
* Linux: See [Trust the certificate with Firefox on Linux](#trust-ff-linux) in this article.
243
247
244
-
### OpenSSL trust
248
+
Add the following JSON to the Firefox policy file:
245
249
246
-
When the ASP.NET Core development certificate is trusted, it is exported to a folder in the current user's home directory. To have [OpenSSL](https://www.openssl.org/) (and clients that consume it) pick up this folder, you need to set the `SSL_CERT_DIR` environment variable. You can either do this in a single session by running a command like `export SSL_CERT_DIR=$HOME/.aspnet/dev-certs/trust:/usr/lib/ssl/certs` (the exact value will be in the output when `--verbose` is passed) or by adding it your (distro- and shell-specific) configuration file (e.g. `.profile`).
250
+
```json
251
+
{
252
+
"policies": {
253
+
"Certificates": {
254
+
"ImportEnterpriseRoots": true
255
+
}
256
+
}
257
+
}
258
+
```
259
+
260
+
The preceding policy file makes Firefox trust certificates from the trusted certificates in the Windows certificate store. The next section provides an alternative approach to create the preceding policy file by using the Firefox browser.
247
261
248
-
This is required to make tools like `curl`trust the development certificate. (Or, alternatively, you can pass `-CAfile` or `-CApath` to each individual `curl` invocation.)
262
+
<aname="trust-ff-ba"></a>
249
263
250
-
Note that this requires 1.1.1h or later or 3.0.0 or later, depending on which major version you're using.
264
+
### Configure trust of HTTPS certificate using Firefox browser
251
265
252
-
If OpenSSL trust gets into a bad state (e.g. if `dotnet dev-certs https --clean` fails to remove it), it is frequently possible to set things right using the [`c_rehash`](https://docs.openssl.org/master/man1/openssl-rehash/) tool.
266
+
Set `security.enterprise_roots.enabled` = `true`using the following instructions:
253
267
254
-
### Overrides
268
+
1. Enter `about:config` in the FireFox browser.
269
+
1. Select **Accept the Risk and Continue** if you accept the risk.
270
+
1. Select **Show All**
271
+
1. Set `security.enterprise_roots.enabled` = `true`
272
+
1. Exit and restart Firefox
255
273
256
-
If you're using another browser with its own Network Security Services (NSS) store, you can use the `DOTNET_DEV_CERTS_NSSDB_PATHS` environment variable to specify a colon-delimited list of NSS directories (i.e. the directory containing `cert9.db`) to which to add the development certificate.
274
+
For more information, see [Setting Up Certificate Authorities (CAs) in Firefox](https://support.mozilla.org/kb/setting-certificate-authorities-firefox) and the [mozilla/policy-templates/README file](https://github.com/mozilla/policy-templates/blob/master/README.md).
257
275
258
-
If you store the certificates you want OpenSSL to trust in a specific directory, you can use the `DOTNET_DEV_CERTS_OPENSSL_CERTIFICATE_DIRECTORY` environment variable to indicate where that is.
276
+
## How to set up a developer certificate for Docker
259
277
260
-
> [!WARNING]
261
-
> If you set either of these variables, it is important that they are set to the same values each time trust is updated. If they change, the tool won't know about certificates in the former locations (e.g. to clean them up)
278
+
See [this GitHub issue](https://github.com/dotnet/AspNetCore.Docs/issues/6199).
262
279
263
-
### Using sudo
280
+
##Trust HTTPS certificate on Linux
264
281
265
-
As on other platforms, development certificates are stored and trusted separately for each user. As a result, if you run `dotnet dev-certs` as a different user (e.g. by using `sudo`), it is _that_ user (e.g. `root`) that will trust the development certificate.
282
+
Establishing trust is distribution and browser specific. The following sections provide instructions for some popular distributions and the Chromium browsers (Edge and Chrome) and for Firefox.
266
283
267
284
### Trust HTTPS certificate on Linux with linux-dev-certs
For more information or to report issues, see the [linux-dev-certs GitHub repository](https://github.com/tmds/linux-dev-certs).
279
296
297
+
### Ubuntu trust the certificate for service-to-service communication
298
+
299
+
The following instructions don't work for some Ubuntu versions, such as 20.04. For more information, see GitHub issue [dotnet/AspNetCore.Docs #23686](https://github.com/dotnet/AspNetCore.Docs/issues/23686).
300
+
301
+
1. Install [OpenSSL](https://www.openssl.org/) 1.1.1h or later. See your distribution for instructions on how to update OpenSSL.
* Ensure the current user's developer certificate is created.
313
+
* Exports the certificate with elevated permissions needed for the `ca-certificates` folder, using the current user's environment.
314
+
* Removing the `-E` flag exports the root user certificate, generating it if necessary. Each newly generated certificate has a different thumbprint. When running as root, `sudo` and `-E` are not needed.
315
+
316
+
The path in the preceding command is specific for Ubuntu. For other distributions, select an appropriate path or use the path for the Certificate Authorities (CAs).
317
+
318
+
<a name="ssl-linux"></a>
319
+
320
+
### Trust HTTPS certificate on Linux using Edge or Chrome
321
+
322
+
# [Ubuntu](#tab/linux-ubuntu)
323
+
324
+
For chromium browsers on Linux:
325
+
326
+
* Install the `libnss3-tools` for your distribution.
327
+
* Create or verify the `$HOME/.pki/nssdb` folder exists on the machine.
328
+
* Export the certificate with the following command:
The path in the preceding command is specific for Ubuntu. For other distributions, select an appropriate path or use the path for the Certificate Authorities (CAs).
336
+
337
+
* Run the following commands:
338
+
339
+
```cli
340
+
certutil -d sql:$HOME/.pki/nssdb -A -t "P,," -n localhost -i /usr/local/share/ca-certificates/aspnet/https.crt
341
+
certutil -d sql:$HOME/.pki/nssdb -A -t "C,," -n localhost -i /usr/local/share/ca-certificates/aspnet/https.crt
342
+
```
343
+
344
+
* Exit and restart the browser.
345
+
346
+
<aname="trust-ff-linux"></a>
347
+
348
+
#### Trust the certificate with Firefox on Linux
349
+
350
+
* Export the certificate with the following command:
The path in the preceding command is specific for Ubuntu. For other distributions, select an appropriate path or use the path for the Certificate Authorities (CAs).
358
+
359
+
* Create a JSON file at `/usr/lib/firefox/distribution/policies.json` with the following command:
360
+
361
+
```sh
362
+
cat <<EOF | sudo tee /usr/lib/firefox/distribution/policies.json
Note: Ubuntu 21.10 Firefox comes as a snap package and the installation folder is `/snap/firefox/current/usr/lib/firefox`.
375
+
376
+
See [Configure trust of HTTPS certificate using Firefox browser](#trust-ff-ba) in this article for an alternative way to configure the policy file using the browser.
377
+
378
+
# [Red Hat Enterprise Linux](#tab/linux-rhel)
379
+
380
+
> [!WARNING]
381
+
> The following instructions are intended for development purposes only. Do not use the certificates generated in these instructions for a production environment.
382
+
383
+
These instructions use Mozilla's *legacy* tool `certutil` at `https://firefox-source-docs.mozilla.org/security/nss/legacy/tools/nss_tools_certutil/index.html`. Instructions may be updated as modern utilities and practices are discovered.
384
+
385
+
> [!CAUTION]
386
+
> Improper use of TLS certificates could lead to spoofing.
387
+
388
+
> [!TIP]
389
+
> Instructions for valid production certificates can be found in the RHEL Documentation.
> If using git, add your certificate to your `${ProjectDirectory}/.gitignore` or `${ProjectDirectory}/.git/info/exclude`.
413
+
> View the [git documentation](https://git-scm.com/docs/gitignore) for information about these files.
414
+
415
+
> [!TIP]
416
+
> You can move your exported certificate outside of your Git repository and replace the occurrences of `${ProjectDirectory}`, in the following instructions, with the new location.
417
+
418
+
### Import The ASP.NET Core Development Certificate
419
+
420
+
> [!IMPORTANT]
421
+
> Replace `${UserProfile}` with the profile you intend to use.
422
+
> Do not replace `$HOME`, it is the environment variable to your user directory.
423
+
424
+
#### Chromium-based Browsers
425
+
426
+
```sh
427
+
certutil -d sql:$HOME/.pki/nssdb -A -t "P,," -n ${CertificateName} -i ${ProjectDirectory}/${CertificateName}.crt
428
+
certutil -d sql:$HOME/.pki/nssdb -A -t "C,," -n ${CertificateName} -i ${ProjectDirectory}/${CertificateName}.crt
429
+
```
430
+
431
+
#### Mozilla Firefox
432
+
433
+
```sh
434
+
certutil -d sql:$HOME/.mozilla/firefox/${UserProfile}/ -A -t "P,," -n ${CertificateName} -i ${ProjectDirectory}/${CertificateName}.crt
435
+
certutil -d sql:$HOME/.mozilla/firefox/${UserProfile}/ -A -t "C,," -n ${CertificateName} -i ${ProjectDirectory}/${CertificateName}.crt
436
+
```
437
+
438
+
#### Create An Alias To Test With Curl
439
+
440
+
> [!IMPORTANT]
441
+
>
442
+
> Don't delete the exported certificate if you plan to test with curl.
443
+
> You'll need to create an alias referencing it in your `$SHELL`'s profile
444
+
445
+
```sh
446
+
alias curl="curl --cacert ${ProjectDirectory}/${CertificateName}.crt"
*[Fedora: Using Shared System Certificates](https://docs.fedoraproject.org/en-US/quick-docs/using-shared-system-certificates/)
558
+
*[Set up a .NET development environment](https://fedoramagazine.org/set-up-a-net-development-environment/) on Fedora.
559
+
560
+
### Trust the certificate with other distros
561
+
562
+
See [this GitHub issue](https://github.com/dotnet/aspnetcore/issues/32842).
563
+
564
+
## Trust HTTPS certificate from Windows Subsystem for Linux
565
+
566
+
The following instructions don't work for some Linux distributions, such as Ubuntu 20.04. For more information, see GitHub issue [dotnet/AspNetCore.Docs #23686](https://github.com/dotnet/AspNetCore.Docs/issues/23686).
567
+
568
+
The [Windows Subsystem for Linux (WSL)](/windows/wsl/about) generates an HTTPS self-signed development certificate, which by default isn't trusted in Windows. The easiest way to have Windows trust the WSL certificate, is to configure WSL to use the same certificate as Windows:
569
+
570
+
* On ***Windows***, export the developer certificate to a file:
The preceding approach is a one time operation per certificate and per WSL distribution. It's easier than exporting the certificate over and over. If you update or regenerate the certificate on windows, you might need to run the preceding commands again.
584
+
367
585
<aname="tcp"></a>
368
586
369
587
## Troubleshoot certificate problems such as certificate not trusted
@@ -776,6 +994,7 @@ For chromium browsers on Linux:
776
994
777
995
```cli
778
996
certutil -d sql:$HOME/.pki/nssdb -A -t "P,," -n localhost -i /usr/local/share/ca-certificates/aspnet/https.crt
997
+
certutil -d sql:$HOME/.pki/nssdb -A -t "C,," -n localhost -i /usr/local/share/ca-certificates/aspnet/https.crt
0 commit comments