ईवेंट्स
Power BI DataViz World Championship
14 फ़र॰, 4 pm - 31 मार्च, 4 pm
प्रवेश करने के 4 अवसरों के साथ, आप एक सम्मेलन पैकेज जीत सकते हैं और लास वेगास में लाइव ग्रैंड फिनाले में जगह बना सकते हैं
अधिक जानेंयह ब्राउज़र अब समर्थित नहीं है.
नवीनतम सुविधाओं, सुरक्षा अपडेट और तकनीकी सहायता का लाभ लेने के लिए Microsoft Edge में अपग्रेड करें.
ASP.NET Core uses HTTPS by default. HTTPS relies on certificates for trust, identity, and encryption.
This document explains how to run pre-built container images with HTTPS using the .NET command-line interface (CLI). For instructions on how to run Docker in development with Visual Studio, see Developing ASP.NET Core Applications with Docker over HTTPS.
This sample requires Docker 17.06 or later of the Docker client.
The current .NET SDK.
A certificate from a certificate authority is required for production hosting for a domain. Let's Encrypt is a certificate authority that offers free certificates.
This document uses self-signed development certificates for hosting pre-built images over localhost
. The instructions are similar to using production certificates. The certificate generated by dotnet dev-certs
is for use with localhost
only and should not be used in an environment like Kubernetes. To support HTTPS within a Kubernetes cluster, use the tools provided by Manage TLS Certificates in a Cluster to setup TLS within pods.
Use dotnet dev-certs
to create self-signed certificates for development and testing.
For production certs:
dotnet dev-certs
tool is not required.The instructions contained in the following section volume mount certificates into containers using Docker's -v
command-line option. You could add certificates into container images with a COPY
command in a Dockerfile, but it's not recommended. Copying certificates into an image isn't recommended for the following reasons:
Use the following instructions for your operating system configuration.
Generate a certificate and configure the local machine:
dotnet dev-certs https -ep %USERPROFILE%\.aspnet\https\aspnetapp.pfx -p <CREDENTIAL_PLACEHOLDER>
dotnet dev-certs https --trust
In the preceding commands, replace <CREDENTIAL_PLACEHOLDER>
with a password.
Run the container image with ASP.NET Core configured for HTTPS in a command shell:
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_PORTS=8001 -e ASPNETCORE_Kestrel__Certificates__Default__Password="<CREDENTIAL_PLACEHOLDER>" -e ASPNETCORE_Kestrel__Certificates__Default__Path=/https/aspnetapp.pfx -v %USERPROFILE%\.aspnet\https:/https/ mcr.microsoft.com/dotnet/samples:aspnetapp
In the preceding code, replace <CREDENTIAL_PLACEHOLDER>
with the password. The password must match the password used for the certificate.
When using PowerShell, 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, validate the mount path to ensure that the certificate loads correctly.
Generate certificate and configure local machine:
dotnet dev-certs https -ep ${HOME}/.aspnet/https/aspnetapp.pfx -p <CREDENTIAL_PLACEHOLDER>
dotnet dev-certs https --trust
On Linux, dotnet dev-certs https --trust
requires .NET 9 SDK or later. For Linux on .NET 8.0.401 SDK and earlier, see your Linux distribution's documentation for trusting a certificate.
In the preceding commands, replace <CREDENTIAL_PLACEHOLDER>
with a password.
Run the container image with ASP.NET Core configured for HTTPS:
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_PORTS=8001 -e ASPNETCORE_Kestrel__Certificates__Default__Password="<CREDENTIAL_PLACEHOLDER>" -e ASPNETCORE_Kestrel__Certificates__Default__Path=/https/aspnetapp.pfx -v ${HOME}/.aspnet/https:/https/ mcr.microsoft.com/dotnet/samples:aspnetapp
In the preceding code, replace <CREDENTIAL_PLACEHOLDER>
with the password. The password must match the password used for the certificate.
Generate certificate and configure local machine:
dotnet dev-certs https -ep %USERPROFILE%\.aspnet\https\aspnetapp.pfx -p <CREDENTIAL_PLACEHOLDER>
dotnet dev-certs https --trust
In the preceding commands, replace <CREDENTIAL_PLACEHOLDER>
with a password. When using PowerShell, replace %USERPROFILE%
with $env:USERPROFILE
.
Run the container image with ASP.NET Core configured for HTTPS:
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_PORTS=8001 -e ASPNETCORE_Kestrel__Certificates__Default__Password="<CREDENTIAL_PLACEHOLDER>" -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: <CREDENTIAL_PLACEHOLDER>
is a placeholder for the Kestrel certificates default password.
The password must match the password used for the certificate. When using PowerShell, replace %USERPROFILE%
with $env:USERPROFILE
.
See Developing ASP.NET Core Applications with Docker over HTTPS for information and samples on how to develop ASP.NET Core applications with HTTPS in Docker containers.
ASP.NET Core uses HTTPS by default. HTTPS relies on certificates for trust, identity, and encryption.
This document explains how to run pre-built container images with HTTPS using the .NET command-line interface (CLI). For instructions on how to run Docker in development with Visual Studio, see Developing ASP.NET Core Applications with Docker over HTTPS.
This sample requires Docker 17.06 or later of the Docker client.
The current .NET SDK.
A certificate from a certificate authority is required for production hosting for a domain. Let's Encrypt is a certificate authority that offers free certificates.
This document uses self-signed development certificates for hosting pre-built images over localhost
. The instructions are similar to using production certificates. The certificate generated by dotnet dev-certs
is for use with localhost
only and should not be used in an environment like Kubernetes. To support HTTPS within a Kubernetes cluster, use the tools provided by Manage TLS Certificates in a Cluster to setup TLS within pods.
Use dotnet dev-certs
to create self-signed certificates for development and testing.
For production certs:
dotnet dev-certs
tool is not required.The instructions contained in the following section volume mount certificates into containers using Docker's -v
command-line option. You could add certificates into container images with a COPY
command in a Dockerfile, but it's not recommended. Copying certificates into an image isn't recommended for the following reasons:
Use the following instructions for your operating system configuration.
Generate a certificate and configure the local machine:
dotnet dev-certs https -ep %USERPROFILE%\.aspnet\https\aspnetapp.pfx -p <CREDENTIAL_PLACEHOLDER>
dotnet dev-certs https --trust
In the preceding commands, replace <CREDENTIAL_PLACEHOLDER>
with a password.
Run the container image with ASP.NET Core configured for HTTPS in a command shell:
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_PORTS=8001 -e ASPNETCORE_Kestrel__Certificates__Default__Password="<CREDENTIAL_PLACEHOLDER>" -e ASPNETCORE_Kestrel__Certificates__Default__Path=/https/aspnetapp.pfx -v %USERPROFILE%\.aspnet\https:/https/ mcr.microsoft.com/dotnet/samples:aspnetapp
In the preceding code, replace <CREDENTIAL_PLACEHOLDER>
with the password. The password must match the password used for the certificate.
When using PowerShell, 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, validate the mount path to ensure that the certificate loads correctly.
Generate certificate and configure local machine:
dotnet dev-certs https -ep ${HOME}/.aspnet/https/aspnetapp.pfx -p <CREDENTIAL_PLACEHOLDER>
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 <CREDENTIAL_PLACEHOLDER>
with a password.
Run the container image with ASP.NET Core configured for HTTPS:
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_PORTS=8001 -e ASPNETCORE_Kestrel__Certificates__Default__Password="<CREDENTIAL_PLACEHOLDER>" -e ASPNETCORE_Kestrel__Certificates__Default__Path=/https/aspnetapp.pfx -v ${HOME}/.aspnet/https:/https/ mcr.microsoft.com/dotnet/samples:aspnetapp
In the preceding code, replace <CREDENTIAL_PLACEHOLDER>
with the password. The password must match the password used for the certificate.
Generate certificate and configure local machine:
dotnet dev-certs https -ep %USERPROFILE%\.aspnet\https\aspnetapp.pfx -p <CREDENTIAL_PLACEHOLDER>
dotnet dev-certs https --trust
In the preceding commands, replace <CREDENTIAL_PLACEHOLDER>
with a password. When using PowerShell, replace %USERPROFILE%
with $env:USERPROFILE
.
Run the container image with ASP.NET Core configured for HTTPS:
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_PORTS=8001 -e ASPNETCORE_Kestrel__Certificates__Default__Password="<CREDENTIAL_PLACEHOLDER>" -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: <CREDENTIAL_PLACEHOLDER>
is a placeholder for the Kestrel certificates default password.
The password must match the password used for the certificate. When using PowerShell, replace %USERPROFILE%
with $env:USERPROFILE
.
See Developing ASP.NET Core Applications with Docker over HTTPS for information and samples on how to develop ASP.NET Core applications with HTTPS in Docker containers.
ASP.NET Core प्रतिक्रिया
ASP.NET Core एक ओपन सोर्स प्रोजेक्ट है. प्रतिक्रिया प्रदान करने के लिए लिंक का चयन करें:
ईवेंट्स
Power BI DataViz World Championship
14 फ़र॰, 4 pm - 31 मार्च, 4 pm
प्रवेश करने के 4 अवसरों के साथ, आप एक सम्मेलन पैकेज जीत सकते हैं और लास वेगास में लाइव ग्रैंड फिनाले में जगह बना सकते हैं
अधिक जानेंप्रशिक्षण
प्रशिक्षण पथ
.NET और ASP.NET Core के साथ क्लाउड-नेटिव ऐप्स और सेवाएँ बनाएँ - Training
स्वतंत्र और ओपन-सोर्स .NET प्लेटफ़ॉर्म का उपयोग करके स्वतंत्र रूप से तैनाती योग्य, उच्च स्केलेबल और लचीला ऐप्स और सेवाएँ बनाएँ। .NET के साथ आप .NET और ASP.NET कोर अनुप्रयोगों और सेवाओं के लिए Docker, Kubernetes, Dapr, Azure Container Registry जैसी लोकप्रिय माइक्रोसर्विस तकनीक का उपयोग कर सकते हैं।
Certification
Microsoft प्रमाणित: Azure डेवलपर सहयोगी - Certifications
Azure फ़ंक्शन बनाने, वेब ऐप्स को लागू करने और प्रबंधित करने, Azure संग्रहण का उपयोग करके समाधान विकसित करने, और बहुत कुछ करने के लिए Microsoft Azure में एंड-टू-एंड समाधान बनाएँ।
दस्तावेज़ीकरण
Hosting ASP.NET Core image in container using docker compose with HTTPS
Learn how to host ASP.NET Core Images with Docker Compose over HTTPS
Learn how to require HTTPS/TLS in an ASP.NET Core web app.
dotnet dev-certs command - .NET CLI
The dotnet dev-certs command generates a self-signed certificate to enable HTTPS use in development.