Tomcat配置Godaddy的ssl证书详细步骤

1.生成tomcat.keystore 密钥文件;

keytool -keysize 2048 -genkey -alias tomcat -keyalg RSA -keystore tomcat.keystore

然后会提示输入DNS 信息及密码:

Enter keystore password:  设置一个用于保护你keystore文件的密码,例如123456
Re-enter new password: 重复上面的密码
What is your first and last name?
  [Unknown]:  yourdomain.com 输入你网站的域名,注意Godaddy的证书一个只能签名一个域名,也就是说 baidu.com 和 www.baidu.com 不是同一个域名,这里应该填写你准备签名的那一个域名。
What is the name of your organizational unit?
  [Unknown]:  Networking 组织单位名称(随便)
What is the name of your organization?
  [Unknown]:  yourdomain.com 组织名称(随便)
What is the name of your City or Locality?
  [Unknown]:  Guangzhou 所在城市(随便)
What is the name of your State or Province?
  [Unknown]:  Guangdong 所在省份(随便)
What is the two-letter country code for this unit?
  [Unknown]:  CN 所在国家的两位代号(随便)
Is CN=www.yourdomain.com, OU=Networking, O=yourdomain.com, L=Shenzhen, ST=Guangdong, C=CN correct?
  [no]:  yes 以上信息正确则输入yes

Enter key password for
    (RETURN if same as keystore password): 输入前面的keystore 密码

 

2.使用keytool 通过tomcat.keystore 生成csr文件,csr.csr 是csr的文件,提前的csr 名称可以自定义;

keytool -certreq -keyalg RSA -alias tomcat -file csr.csr -keystore tomcat.keystore

3.官方申请证书;

进入到GoDaddy的ssl证书管理界面,根据提示进入输入 CSR  的页面,用文本编辑器打开刚才生成的 csr.csr 文件,把里面的文本内容复制粘贴到页面的表单里即可。SSL 证书商会根据你的域名发送一封验证邮件到域名注册者的Email(所以你要提前注意你的域名注册的Email地址是什么,如果是错误的话需要先修正,否则收不到验证Email)。这个过程可能需要几分钟或者几小时,收到验证Email之后点击里面的链接地址就完成私钥签名了;

4.

将官方生成的证书导入到 tomcat.keystore 里面;

登录到你购买 SSL 的证书商,下载你的网站已签名的证书文件,在 GoDaddy 里你下载会得到一个压缩包,里面放有(domain.crt,gd_bundle-g2-g1.crt,gdig2.crt)

导入的流程顺序:根证书,中级证书,个人证书;

我所下载的包里面包含:(f91dc12f8b1fb94e.crt,gd_bundle-g2-g1.crt,gdig2.crt)

所以根证书是:gd_bundle-g2-g1.crt   中级证书:gdig2.crt  个人证书:f91dc12f8b1fb94e.crt

请注意:在默认安装证书时,到最后安装个人证书会提示:keytool error: java.lang.Exception: Failed to establish chain from reply

解决方法:原因是官方下载的根证书与中级证书可能是过期,你到它的repository里找到对应名称的根证书下载覆盖

5.导入证书:

keytool -import -alias root -keystore tomcat.keystore -trustcacerts -file gd_bundle-g2-g1.crt

keytool -import -alias intermed -keystore tomcat.keystore -trustcacerts -file gdig2.crt

keytool -import -alias tomcat -keystore tomcat.keystore -trustcacerts -file f91dc12f8b1fb94e.crt

6.tomcat 配置server.xml ,先在tomcat 目录下面新建一个ssl 文件夹存放tomcat.keystore 文件

<Connector port="8443" maxThreads="200" protocol="org.apache.coyote.http11.Http11NioProtocol" 
          scheme="https" secure="true" SSLEnabled="true"
          keystoreFile="/usr/local/tomcat/tomcat.keystore" keystorePass="xxx"
          clientAuth="false" sslProtocol="TLS"/>

7.启动tomcat,添加防火墙端口,测试

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值