在 C# 中使用 HTTPS,方法是使用证书运行容器。
如果需要使用证书运行容器,请按照以下步骤生成证书并配置本地计算机:
使用证书运行 IronSecureDoc 容器
1.生成证书:
# Generates a new HTTPS certificate for use with ASP.NET Core.
# Saves the certificate at the specified path and protects it with a password.
dotnet dev-certs https -ep %USERPROFILE%\.aspnet\https\ironsecuredoc.pfx -p <CREDENTIAL_PLACEHOLDER>
# Trusts the generated certificate on your local machine.
dotnet dev-certs https --trust # Generates a new HTTPS certificate for use with ASP.NET Core.
# Saves the certificate at the specified path and protects it with a password.
dotnet dev-certs https -ep %USERPROFILE%\.aspnet\https\ironsecuredoc.pfx -p <CREDENTIAL_PLACEHOLDER>
# Trusts the generated certificate on your local machine.
dotnet dev-certs https --trust代替<CREDENTIAL_PLACEHOLDER>使用密码。
2.运行 Docker 容器:
# Runs the IronSecureDoc Docker container with both HTTP and HTTPS ports exposed.
docker container run -d \
-p 8081:8081 -p 8080:8080 \ # Maps container ports to host ports for HTTP and HTTPS.
-e HTTP_PORTS=8080 \ # Sets the HTTP port for the application.
-e HTTPS_PORTS=8081 \ # Sets the HTTPS port for the application.
-e IronSecureDoc_LicenseKey=<IRONSECUREDOC_LICENSE_KEY> \ # Provides the IronSecureDoc license key.
-e ENVIRONMENT=Production \ # Configures the environment as Production.
-v %USERPROFILE%\.aspnet\https:/https:ro \ # Mounts the directory to the container as read-only.
-e CERTIFICATE_PATH=%USERPROFILE%\.aspnet\https\ironsecuredoc.pfx \ # Specifies the path to the certificate in the container.
-e CERTIFICATE_PASSWORD=<CERTIFICATE_PASSWORD> \ # Password for the certificate.
ironsoftwareofficial/ironsecuredoc:latest # Specifies the Docker image to use. # Runs the IronSecureDoc Docker container with both HTTP and HTTPS ports exposed.
docker container run -d \
-p 8081:8081 -p 8080:8080 \ # Maps container ports to host ports for HTTP and HTTPS.
-e HTTP_PORTS=8080 \ # Sets the HTTP port for the application.
-e HTTPS_PORTS=8081 \ # Sets the HTTPS port for the application.
-e IronSecureDoc_LicenseKey=<IRONSECUREDOC_LICENSE_KEY> \ # Provides the IronSecureDoc license key.
-e ENVIRONMENT=Production \ # Configures the environment as Production.
-v %USERPROFILE%\.aspnet\https:/https:ro \ # Mounts the directory to the container as read-only.
-e CERTIFICATE_PATH=%USERPROFILE%\.aspnet\https\ironsecuredoc.pfx \ # Specifies the path to the certificate in the container.
-e CERTIFICATE_PASSWORD=<CERTIFICATE_PASSWORD> \ # Password for the certificate.
ironsoftwareofficial/ironsecuredoc:latest # Specifies the Docker image to use.代替<IRONSECUREDOC_LICENSE_KEY>和<CERTIFICATE_PASSWORD>分别使用您的 IronSecureDoc 许可证密钥和证书密码。
常见问题解答
为什么 HTTPS 对文档安全很重要?
HTTPS 对文档安全至关重要,因为它加密了传输的数据,确保敏感信息在传输过程中保持机密并防止拦截。
如何为我的应用程序创建 HTTPS 证书?
您可以通过运行命令dotnet dev-certs https -ep %USERPROFILE%\.aspnet\https\ironsecuredoc.pfx -p <CREDENTIAL_PLACEHOLDER>创建 HTTPS 证书,该命令生成用于 ASP.NET Core 的新证书。
怎样确保我的 HTTPS 证书在本地机器上被信任?
要在本地机器上信任您的 HTTPS 证书,使用命令dotnet dev-certs https --trust。此命令将您的系统配置为信任生成的证书。
运行支持 HTTPS 的 Docker 容器的过程是什么?
要运行支持 HTTPS 的 Docker 容器,开放 HTTP 和 HTTPS 端口,设置必要的环境变量如IronSecureDoc_LicenseKey和CERTIFICATE_PASSWORD,并将证书目录挂载为只读。
在 Docker 设置中应该配置哪些端口以支持 HTTPS?
在 Docker 设置中进行 HTTPS 配置,通过暴露端口 8081 作 HTTPS 和端口 8080 作 HTTP ,将容器端口映射到主机端口。
如何将证书密码传递给 Docker 容器?
在执行 Docker run 命令时,使用环境变量CERTIFICATE_PASSWORD将证书密码传递给 Docker 容器。
在 Docker 中配置为 "Production" 环境需要哪些步骤?
要在 Docker 中配置为“Production”环境,在您的 Docker run 命令中设置环境变量ENVIRONMENT=Production。
在 Docker 命令中如何处理占位符?
在 Docker 命令中,用您的实际 IronSecureDoc 许可证密钥和证书密码替换占位符如<IRONSECUREDOC_LICENSE_KEY>和<CERTIFICATE_PASSWORD>以确保正常功能。





