cas5.3 https证书配置教程

证书生成

这个我写了好几遍了,我就不重复复制粘贴证书的生成了 
参考文章:http://blog.csdn.net/yelllowcong/article/details/78805420

方式一:修改server.xml配置ssl

配置server.xml

配置8443端口

<!--设定http/1.1协议 还有配置keystore的位置和密码-->
<Connector port="8443" protocol="HTTP/1.1"  
               minSpareThreads="5" maxSpareThreads="75"    
               enableLookups="true" disableUploadTimeout="true"      
               acceptCount="100"  maxThreads="200"    
               scheme="https" secure="true" SSLEnabled="true"    
               clientAuth="false" sslProtocol="TLS"    
               keystoreFile="D:/keystore"      
               keystorePass="yellowcong"/>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

这里写图片描述

方式二:修改application.properties配置配置ssl

1、查看证书的别名

#D:/tomcat.keystore 是证书存放的目录
keytool -list -keystore D:/tomcat.keystore
  • 1
  • 2

下图可以看到,我的证书的别名是tomcat. 
这里写图片描述

2、配置application.properties

在springboot中,添加如下配置信息即可完成证书的配置。

#SSL配置
server.ssl.enabled=true
#这个classpath 表示类路径
#还可使用 file ,来使用文件系统路径
server.ssl.key-store=classpath:tomcat.keystore
server.ssl.key-store-password=yellowcong
#查看别名,别名不是瞎写的
#keytool -list -keystore D:/tomcat.keystore
server.ssl.keyAlias=tomcat
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

这里写图片描述

启动服务

这玩意启动起来,真的很慢啊,我电脑是i5 3470,固态硬盘,居然也要200多秒,才能启动起来。

#启动cas服务
build.cmd debug 
  • 1
  • 2

这里写图片描述

常见问题

1、Caused by: java.io.IOException: Alias name [yellowcong.com] does not identify a key entry

在springboot中,设定证书的时候,报了这个破玩意错误,server.ssl.keyAlias 配置有问题。

Caused by: java.io.IOException: Alias name [yellowcong.com] does not identify a
key entry
        at org.apache.tomcat.util.net.jsse.JSSEUtil.getKeyManagers(JSSEUtil.java
:225) ~[tomcat-embed-core-8.5.24.jar!/:8.5.24]
        at org.apache.tomcat.util.net.AbstractJsseEndpoint.createSSLContext(Abst
ractJsseEndpoint.java:114) ~[tomcat-embed-core-8.5.24.jar!/:8.5.24]
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

这里写图片描述

解决办法,就是通过keytool的命令,查看别名信息。

#查询
keytool -list -keystore D:/tomcat.keystore
#可以发现,我的别名是tomcat...我填错了,所以报错
  • 1
  • 2
  • 3

这里写图片描述

猜你喜欢

转载自blog.csdn.net/zn65786412qq/article/details/80940749