简体   繁体   English

将SSL证书添加到Docker网站

[英]Adding SSL certificates to Website to Docker

I have a website that runs on ssl ie https, I want to deploy it to Docker Windows Containers with Docker Desktop for Windows . 我有一个在ssl即https上运行的网站,我想使用Docker Desktop for Windows将其部署到Docker Windows容器中。 So I wanted to ask how can it be done, I have added the certificates to the container, and when I use 所以我想问一问如何做到,我已经将证书添加到了容器中,以及何时使用

 RUN powershell -NoProfile -Command   certmgr.exe -add MyCert.cer -s -r localMachine trustedpublisher

It gives this error. 它给出了这个错误。

certmgr.exe : The term 'certmgr.exe' is not recognized as the name of a cmdlet, function, script file, or operable program. certmgr.exe:术语“ certmgr.exe”未被识别为cmdlet,函数,脚本文件或可运行程序的名称。 Check the spelling of the name, or if a path was included, verify that the path is correct and try again. 检查名称的拼写,或者是否包含路径,请验证路径是否正确,然后重试。

So can you explain how would it be done? 那么您能解释一下怎么做吗?

certmgr.exe 证书管理器

needs Visual Studio so it cant be run in Containers. 需要Visual Studio,因此无法在容器中运行。 Following is a way to do it if it helps anyone. 如果有帮助,则遵循以下方法可以做到。 Add this in the docker file when you are creating the image 创建映像时将其添加到docker文件中

RUN mkdir C:\cert

#cert folder contains the certificates YourCertificate.cer & Name.pfx
ADD cert/ /cert    

RUN powershell -NoProfile -Command \
    certutil -addstore "Root" "C:/cert/YourCertificate.cer"

RUN powershell -NoProfile -Command \
    certutil -importpfx -p "password" "C:/cert/Name.pfx"

RUN powershell -NoProfile -Command \    
New-WebBinding -Name "YourWebsite" -IP "*" -Port 1234 -Protocol https

RUN powershell -NoProfile -Command \
get-item cert:\LocalMachine\MY\thumbprint-of-your-cert | New-Item 0.0.0.0!1234

1234 is the port which you can bind with your website. 1234是可以与您的网站绑定的端口。 It will bind your website to the certificate. 它将您的网站绑定到证书。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM