IronSecureDoc 教程 使用 HTTPS 在 C# 中使用 HTTPS,方法是使用憑證執行容器。 Curtis Chau 更新:11月 25, 2025 下載 IronSecureDoc 免費下載 開始免費試用 法學碩士副本 法學碩士副本 將頁面複製為 Markdown 格式,用於 LLMs 在 ChatGPT 中打開 請向 ChatGPT 諮詢此頁面 在雙子座打開 請向 Gemini 詢問此頁面 在 Grok 中打開 向 Grok 詢問此頁面 打開困惑 向 Perplexity 詢問有關此頁面的信息 分享 在 Facebook 上分享 分享到 X(Twitter) 在 LinkedIn 上分享 複製連結 電子郵件文章 This article was translated from English: Does it need improvement? Translated View the article in English 如果需要使用憑證執行容器,請依照下列步驟產生憑證並設定本機: 使用憑證運行 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 SHELL 代替<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. SHELL 代替<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 運行命令時,使用環境變量 CERTIFICATE_PASSWORD 將證書密碼傳遞給 Docker 容器。 要將環境配置為 Docker 中的「生產環境」需要哪些步驟? 要將環境配置為 Docker 中的「生產環境」,請在你的 Docker 運行命令中設置環境變量 ENVIRONMENT=Production。 如何在 Docker 命令中處理佔位符? 在 Docker 命令中,將佔位符如 <IRONSECUREDOC_LICENSE_KEY> 和 <CERTIFICATE_PASSWORD> 替換為您實際的 IronSecureDoc 授權密鑰和證書密碼,以確保正常功能。 Curtis Chau 立即與工程團隊聊天 技術作家 Curtis Chau 擁有卡爾頓大學計算機科學學士學位,專注於前端開發,擅長於 Node.js、TypeScript、JavaScript 和 React。Curtis 熱衷於創建直觀且美觀的用戶界面,喜歡使用現代框架並打造結構良好、視覺吸引人的手冊。除了開發之外,Curtis 對物聯網 (IoT) 有著濃厚的興趣,探索將硬體和軟體結合的創新方式。在閒暇時間,他喜愛遊戲並構建 Discord 機器人,結合科技與創意的樂趣。 準備好開始了嗎? Version: 2024.10 剛發表 免費下載 檢視授權