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_LICENSE_KEY>和<CERTIFICATE_PASSWORD>替換為您實際的IronSecureDoc授權金鑰和憑證密碼。
常見問題
HTTPS 為何對文件安全性至關重要?
HTTPS 對於文件安全性至關重要,因為它會對傳輸中的資料進行加密,確保敏感資訊在傳輸過程中保持機密性,並防止遭竊聽。
我該如何為我的應用程式建立 HTTPS 憑證?
您可以透過執行指令 `dotnet dev-certs https -ep %USERPROFILE%\.aspnet\https\IronSecureDoc.pfx -p` 來建立 HTTPS 憑證,此指令會產生一個可用於 .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 中將環境設定為「Production」,請在 Docker 執行指令中設定環境變數 ENVIRONMENT=Production。
在 Docker 指令中應如何處理佔位符?
在 Docker 指令中,請將 和 等佔位符替換為您的實際 IronSecureDoc 授權金鑰和憑證密碼,以確保功能正常運作。





