在 Windows 平台上,您可以使用 Certbot 的 Windows 版本来生成 SSL/TLS 证书。下面是基本步骤:

  1. 下载并安装 Certbot:访问 Certbot 官方网站下载适合 Windows 系统的 Certbot,并按照安装向导完成安装。

  2. 安装完成后,在包含certbot.exe的bin文件夹打开命令提示符:在开始菜单中搜索 “CMD”,然后右键单击 “命令提示符” 选项卡并选择 “以管理员身份运行”。

  3. 运行 Certbot 命令:使用以下命令生成 SSL/TLS 证书。

    1
    >certbot certonly --manual --preferred-challenges=http -d www.lightcat.live -d www.lightcat.online #如果有两个个域名则写两个-d domain

    这将在 Windows 上启动 Certbot,使用 “standalone” 模式并指定您的域名(例如 example.com)为目标,以获取证书。

  4. image-20230503012217314

软件提示要在网站特定的链接返回特定的值以验证网站是否为自己拥有的。下面以django为例进行配置。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#在views文件设置视图函数
from django.http import HttpResponse

def letsencrypt(request, challenge):
response = HttpResponse("challenge")
return response

#在urls.py中建立以下映射
from django.urls import path
from .views import letsencrypt

urlpatterns = [
# ... 其他 URL 映射 ...
path(".well-known/acme-challenge/<str:challenge>/", letsencrypt),
]

设置完成后输入enter进行确认

image-20230503012852117

提示证书生成成功,并给出证书存在的路径以及到期时间。

5.安装证书:在证书生成成功后,在frp中添加设置。设置完成后即可通过https访问

1
2
3
4
5
6
7
8
9
10
11
[web-https]
type = https
custom_domains = www.lightcat.online
plugin = https2http
plugin_local_addr = 127.0.0.1:80
# HTTPS 证书相关的配置
plugin_crt_path = C:\Certbot\live\www.lightcat.online\fullchain.pem
plugin_key_path = C:\Certbot\live\www.lightcat.online\privkey.pem
plugin_host_header_rewrite = 127.0.0.1
plugin_header_X-From-Where = frp

5.证书过期时,通过

1
>certbot certonly --manual --preferred-challenges=http -d www.lightcat.live -d www.lightcat.online

对证书进行更新