OpenWrt 在没有80\443端口、不能dns验证的情况下为自己的域名申请免费ssl证书

本方法适用于使用OpenWrt 在没有80\443端口、不能dns验证的情况下为自己的域名申请免费ssl证书。
提示:
1、如果你的网络的80或者443端口是开放状态,可直接使用https://letsencrypt.org/进行ssl申请,使用acme.sh脚本可快速完成。
2、如果你的网络ddns服务提供商服务到位,可以使用dns验证的方法,也更加方便。

本流程适用于上述两种方法都失效的情况下,采用邮箱验证来完成域名所属验证。

OpenWrt 分支: 22.03.3 内核: 5.10.161

在zerossl上申请证书

在申请的时候需要验证自己域名的所有权,选择邮箱验证(幸好zerossl支持这种方式)

在openwrt上架设邮箱服务器

zerossl是通过发送邮件到包含域名的邮箱地址的,如 admin@你的域名,所以必须在openwrt上架设邮箱服务器。

使用postfix作为架设邮箱服务器的工具,可以通过命令行或者luci安装 postfix,我这里安装的版本是3.5.8-2。
安装完成之后使用vim /etc/postfix/main.cf编辑配置文件,将下列配置替换域名直接粘贴到最后区域,覆盖之前的内容。

inet_interfaces = all
inet_protocols = all
default_database_type = cdb
config_directory = /etc/postfix
command_directory = /usr/sbin
daemon_directory = /usr/libexec/postfix
shlib_directory = /usr/lib/postfix
manpage_directory = no
data_directory = /usr/var/lib/postfix
queue_directory = /usr/var/spool/postfix
mail_spool_directory = /usr/var/mail
myhostname = 你的域名
mynetworks_style = subnet

经过测试这块代码这样是可以运行的,如果比较懂的可以自行调整。

  • 可以先检查配置文件是否有问题:
[root@OpenWrt:10:56 PM /] # /etc/init.d/postfix postinst postfix: warning: smtputf8_enable is true, but EAI support is not compiled in postfix: warning: smtputf8_enable is true, but EAI support is not compiled in postfix: warning: smtputf8_enable is true, but EAI support is not compiled in newaliases: warning: smtputf8_enable is true, but EAI support is not compiled in postalias: warning: smtputf8_enable is true, but EAI support is not compiled in postmap: warning: smtputf8_enable is true, but EAI support is not compiled in postfix: warning: smtputf8_enable is true, but EAI support is not compiled in postsuper: warning: smtputf8_enable is true, but EAI support is not compiled i 

我这里有这样的warning,不影响功能。

  • 运行:
[root@OpenWrt:10:56 PM /] # /etc/init.d/postfix restart 

服务器运行成功,不要忘了调整防火墙设置,以免邮件发送不进来。

zerossl上只能选择固定的几种邮箱地址来验证,所以root账户是不行的,我选择的是admin@你的域名来验证。这时候可以通过在openwrt上安装shadow-useradd来添加用户,安装完成之后:
运行:

完成之后,重启postfix:/etc/init.d/postfix restart

zerossl域名验证

选择admin@你的域名来进行验证,这时候zerossl会发送一个邮件到这个地址。
使用vim /usr/var/mail/root来查看邮件内容,按照提示完成验证,然后下载证书文件。

上传证书

参考链接:
http://cn.linux.vbird.org/linux_server/0380mail.php#postfix
https://letsencrypt.org/zh-cn/docs/allow-port-80/

原文链接:https://blog.csdn.net/a553455/article/details/128638098?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522168466843816800184173244%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fblog.%2522%257D&request_id=168466843816800184173244&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~blog~first_rank_ecpm_v1~times_rank-6-128638098-null-null.blog_rank_default&utm_term=NAS%E3%80%81%E7%BE%A4%E6%99%96%E3%80%81%E9%98%BF%E9%87%8C%E4%BA%91%E3%80%81%E5%9F%9F%E5%90%8D%E8%A7%A3%E6%9E%90%E3%80%81%E5%86%85%E7%BD%91%E7%A9%BF%E9%80%8F%E3%80%81ipv6%E3%80%81ddns%E3%80%81%E8%BD%BB%E9%87%8F%E7%BA%A7%E4%BA%91%E6%9C%8D%E5%8A%A1%E5%99%A8%E3%80%81%E9%93%81%E5%A8%81%E9%A9%AC%E3%80%81%E5%A8%81%E8%81%94%E9%80%9A%E3%80%81DSM%E3%80%81DSM6.0%E3%80%81%E7%BE%A4%E6%99%96nas%E3%80%81%E4%BA%91%E6%9C%8D%E5%8A%A1%E5%99%A8%E3%80%81%E8%9C%97%E7%89%9B%E6%98%9F%E9%99%85%E3%80%81%E9%BB%91%E7%BE%A4%E6%99%96%E3%80%81docker%E3%80%81%E5%AE%B9%E5%99%A8%E9%95%9C%E5%83%8F%E3%80%81%E5%9F%9F%E5%90%8D%E6%B3%A8%E5%86%8C%E3%80%81%E5%AE%9D%E5%A1%94%E3%80%81%E5%8F%8D%E5%90%91%E4%BB%A3%E7%90%86%E3%80%81nginx%E3%80%81frp%E3%80%81%E5%8A%A8%E6%80%81%E5%9F%9F%E5%90%8D%E8%A7%A3%E6%9E%90

© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享