USE HTTPS in C# by Running the Container with a Certificate
如果您需要使用證書運行容器,請按照以下步驟生成證書並配置本地機器:
使用憑證運行IronSecureDoc容器
生成證書:
# 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 --trustSHELL將
<CREDENTIAL_PLACEHOLDER>替換為密碼。運行 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.SHELL將
IronSecureDoc授權金鑰和憑證密碼。
常見問題
為什麼HTTPS對文件安全很重要?
HTTPS對文件安全至關重要,因為它加密傳輸中的資料,確保敏感資訊在傳輸過程中保持機密和防止截取。
我如何為我的應用程式建立HTTPS證書?
您可以通過執行命令dotnet dev-certs https -ep %USERPROFILE%\.aspnet\https\ironsecuredoc.pfx -p <CREDENTIAL_PLACEHOLDER>建立用於ASP.NET Core的新證書。
如何確保我的HTTPS證書在本地機器上被信任?
要在本地機器上信任您的HTTPS證書,請使用命令 dotnet dev-certs https --trust。此命令將配置系統以信任生成的證書。
運行支持HTTPS的Docker容器的過程是什麼?
要運行支持HTTPS的Docker容器,公開HTTP和HTTPS端口,設置必要的環境變數如IronSecureDoc_LicenseKey和CERTIFICATE_PASSWORD,並將證書目錄掛載為只讀。
在Docker設置中應該配置哪些端口以支持HTTPS?
在Docker設置中,通過公開8081端口支持HTTPS,8080端口支持HTTP來映射容器端口到主機端口。
如何將證書密碼傳遞給Docker容器?
當執行Docker run命令時,使用環境變數CERTIFICATE_PASSWORD將證書密碼傳遞給Docker容器。
配置Docker為'Production'環境需要哪些步驟?
要將Docker配置為'Production'環境,在Docker run命令中設置環境變數ENVIRONMENT=Production。
在Docker命令中應如何處理佔位符?
在Docker命令中,將<IRONSECUREDOC_LICENSE_KEY>和<CERTIFICATE_PASSWORD>等佔位符替換為實際的IronSecureDoc授權金鑰和證書密碼以保證正常運行。





