申请Let's Encrypt泛域名免费证书(无需域名80端口)

 

 

1、前言

最近有个外网域名需要申请证书,准备用Let's Encrypt证书,毕竟免费吗。可惜脚本中会验证域名的80端口,很不幸80端口因为某些原因无法开放,后来无意中发现一个方法,结合Neilpang/acme.sh和泛域名,这里记录下。

 

Neilpang/acme.sh参考:https://github.com/Neilpang/acme.sh/wiki/%E8%AF%B4%E6%98%8E

 

2、步骤

 

2.1 执行安装脚本

 

curl https://get.acme.sh | sh 或者

wget -O - https://get.acme.sh | sh 或者

curl https://raw.githubusercontent.com/Neilpang/acme.sh/master/acme.sh | INSTALLONLINE=1 sh 或者

wget -O - https://raw.githubusercontent.com/Neilpang/acme.sh/master/acme.sh | INSTALLONLINE=1 sh

 

脚本安装在~/.acme.sh目录下

 

2.2 申请泛域名证书

 

./acme.sh --issue -d *.qwcsp.cf -d *.qwcsp.tk --dns --yes-I-know-dns-manual-mode-enough-go-ahead-please

 

2.3 域名解析服务器添加域名的TXT解析

红方框中就是需要的信息。

 

2.4 获取Let's Encrypt泛域名证书

2.4.1 查看TXT信息步骤:

2.4.1.1 安装nslookup

yum install -y bind-utils

2.4.1.2 查看信息

nslookup -q=TXT baidu.com

 

2.4.2 DSN解析生效后,运行命令

./acme.sh --renew -d *.qwcsp.cf -d *.qwcsp.tk --dns --yes-I-know-dns-manual-mode-enough-go-ahead-please

 

2.5 证书说明

在~/.acme.sh目录下会产生“*.域名”的文件夹,里面就是证书,fullchain.cer是完整的证书,具体的证书区分见

证书格式说明 openssl生成自签证书 中的证书类型说明。

 

 

[root@node190 .acme.sh]# tree *.qwcsp.cf

*.qwcsp.cf

├── ca.cer

├── fullchain.cer

├── *.qwcsp.cf.cer 证书

├── *.qwcsp.cf.conf

├── *.qwcsp.cf.csr 证书申请文件

├── *.qwcsp.cf.csr.conf

├── *.qwcsp.cf.key 私钥

└── qwcsp.cf.pem

 

附:

pem格式生成命令:

cat fullchain.cer \*.qwcsp.cf.key | tee qwcsp.cf.pem

强制更新命令:

./acme.sh --force --renew -d *.qwcsp.cf -d *.qwcsp.tk --dns --yes-I-know-dns-manual-mode-enough-go-ahead-please

 

2.6 生成tomcat的证书

# 导出.p12格式的证书

/root/.acme.sh/*.qwcsp.cf

[root@node190 *.qwcsp.cf]# openssl pkcs12 -export -in fullchain.cer -inkey *.qwcsp.cf.key -out *.qwcsp.cf.p12 -name tomcat_letsencrypt

Enter Export Password:

Verifying - Enter Export Password:

 

# 再将证书由.p12格式转换成.jks格式

$ keytool -importkeystore -deststorepass '123456' -destkeypass '123456' -destkeystore *.qwcsp.cf.jks -srckeystore *.qwcsp.cf.p12 -srcstoretype PKCS12 -srcstorepass '123456' -alias tomcat_letsencrypt

# 修改tomcat配置

修改 %tomcat%/conf/server.xml 文件,添加 keystoreFile 和 keystorePass 两行配置。其中,keystoreFile 指向 jks 证书文件,而 keystorePass 则为证书的密钥。修改后的关键配置如下:

<Connector port="8443" protocol="org.apache.coyote.http11.Http11Protocol" SSLEnabled="true"

maxThreads="150" scheme="https" secure="true"

clientAuth="false" sslProtocol="TLS"

keystoreFile="/home/test/*.qwcsp.cf.jks"

keystorePass="123456"

/>

 

 

 

 

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值