在 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 中將環境配置為「生產」需要哪些步驟?
若要在 Docker 中將環境配置為「生產」環境,請在 Docker 執行指令中設定環境變數ENVIRONMENT=Production 。
Docker 指令中應該如何處理佔位符?
在 Docker 命令中,請將<IRONSECUREDOC_LICENSE_KEY>和<CERTIFICATE_PASSWORD>等佔位符替換為您實際的 IronSecureDoc 許可證密鑰和證書密碼,以確保其正常運作。





