gpt4 book ai didi

docker - 将 SSL 证书添加到网站到 Docker

转载 作者:太空宇宙 更新时间:2023-11-03 14:05:45 27 4
gpt4 key购买 nike

我有一个在 ssl 即 https 上运行的网站,我想使用 Windows 版 Docker 桌面 将它部署到 Docker Windows 容器。所以我想问一下怎么办,我已经把证书加到容器里了,什么时候用

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

它给出了这个错误。

certmgr.exe : The term 'certmgr.exe' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

那么您能解释一下它是如何完成的吗?

最佳答案

certmgr.exe

需要 Visual Studio,所以它不能在容器中运行。以下是一种方法,如果它可以帮助任何人。创建镜像时在 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 是您可以与您的网站绑定(bind)的端口。它将您的网站绑定(bind)到证书。

关于docker - 将 SSL 证书添加到网站到 Docker,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41821491/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com