在windows Server安装Let‘s Encrypt的SSL证书

备注-->1、有一个大坑:用openssl软件把.pem文件合并转换成.pfx后,在IIS中导入会提示“密码不正确”,这是openssl版本造成的,换成低版本openssl v1.1 来转换即可。(据说是因为高版本默认的加密是AES256,而IIS不支持这种加密)

备注-->2、acme-challenge (验证)环节失败,请检查防火墙。关闭/打开防火墙的命令:netsh advfirewall set allprofiles state off 或者 on

1、到官网(https://certbot.eff.org/instructions?ws=webproduct&os=windows)下载 certbot客户端。

2、安装客户端(全部默认安装即可)

3、暂停IIS中的网站

开始菜单中找到并运行“Certbot”,输入指令:

certbot certonly --standalone

然后根据提示1输入邮箱、2同意协议、3拒绝推广邮件、4输入域名 

正常的话,会提示接收成功,已经保存到xx目录

如果失败:

Certbot failed to authenticate some domains (authenticator: standalone). The Certificate Authority reported these problems:
  Domain: xxxxx.com
  Type:   connection
  Detail: 12.34.56.78: Fetching http://xxxxx.com/.well-known/acme-challenge/xxxxxx: Timeout during connect (likely firewall problem)

Hint: The Certificate Authority failed to download the challenge files from the temporary standalone webserver started by Certbot on port 80. Ensure that the listed domains point to this machine and that it can accept inbound connections from the internet.

Some challenges have failed.
Ask for help or search for solutions at https://community.letsencrypt.org. See the logfile C:\Certbot\log\letsencrypt.log or re-run Certbot with -v for more details.

如果提示失败,通常是防火墙问题。暂时关闭防火墙,方法:请注意,在进行调试后请记得重新启用防火墙以确保服务器的安全性。

打开 PowerShell 窗口(以管理员身份运行)。你可以在开始菜单中找到 PowerShell,右键点击并选择“以管理员身份运行”。输入以下命令来停用 Windows Defender 防火墙:

netsh advfirewall set allprofiles state off

如果需要启用防火墙,可以使用以下命令:

netsh advfirewall set allprofiles state on

下载openssl软件(IIS请下载v1.1 light 版本)下载地址:

https://slproweb.com/products/Win32OpenSSL.html

用openssl软件 把Certbot获取的4个文件中的3个(私钥文件(privkey.pem)证书文件(cert.pem)链文件(fullchain.pem))合并转换成pfx文件 (记住转换时设置的导出密码)

openssl pkcs12 -export -out server.pfx -inkey privkey.pem -in fullchain.pem
openssl pkcs12 -export -out F:\pem\mysite.pfx -inkey F:\pem\privkey.pem -in F:\pem\fullchain.pem

 

双击pfx文件导入到IIS。(需输入创建pfx文件时设置的密码)

IIS中添加并绑定证书:

添加:

 绑定

最后,要记得开通服务器的433端口

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
Windows下配置Nginx的SSL证书,你可以按照以下步骤进行操作: 1. 获取SSL证书: 首先,你需要从证书颁发机构(CA)获取有效的SSL证书。这通常涉及到购买证书或使用免费的证书颁发机构(如Let's Encrypt)来获取证书。 2. 安装SSL证书: 将获取的SSL证书文件(通常包括.pem或.crt文件)保存到你的Windows计算机的某个位置,比如C:\ssl目录下。 3. 配置Nginx: 打开Nginx的配置文件(通常是nginx.conf),找到与SSL相关的配置部分。 ``` server { listen 443 ssl; server_name yourdomain.com; ssl_certificate C:/ssl/your_certificate.crt; ssl_certificate_key C:/ssl/your_private_key.key; # 其他 SSL 配置... } ``` 在以上示例中,你需要将`yourdomain.com`替换为你的域名,并将`C:/ssl/your_certificate.crt`和`C:/ssl/your_private_key.key`替换为你保存证书的路径和文件名。 4. 重启Nginx: 保存配置文件后,重新启动Nginx服务器以使更改生效。 如果你使用的是Windows服务来运行Nginx,则可以通过以下命令重启服务: ``` net stop nginx net start nginx ``` 如果你是直接运行Nginx可执行文件,则需要关闭当前运行的Nginx进程,并重新启动Nginx。 现在,你的Nginx服务器应该已成功配置SSL证书,可以通过HTTPS访问你的网站了。请确保你的域名已正确解析到你的服务器IP地址,并且服务器的防火墙已打开相应的端口(通常是443)。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值