1、安装certbot
brew install certbot
2、执行命令
sudo certbot certonly -d "iot.xxx.cn" --manual --preferred-challenges dns --server https://acme-v02.api.letsencrypt.org/directory

3、域名解析配置

4、按Enter继续
5、生成证书

fullchain.pem 是证书文件
privkey.pem 是私钥
放到nginx或者上传到其他需要证书的地方即可,默认证书有效期90天。