Tomcat下CAS Server证书配置

  • 生成证书
    keytool -genkey -alias cas -keyalg RSA -keystore cas.keystore

    CN的名字必须和cas server的域名一直。比如localhost。这里证书密码为test1234。

  • 导出证书
    keytool -export -file cas.crt -alias cas -keystore cas.keystore

  • 导入证书到JRE
    keytool -import -keystore "${jdk_path}\jre\lib\security\cacerts" --file cas.crt -alias cas

    执行需要管理者权限,Windows下需要以“管理者”运行cmd。

  • tomcat的 server.xml 的配置

<!-- Define a SSL Coyote HTTP/1.1 Connector on port 8443 -->
<Connector protocol="org.apache.coyote.http11.Http11NioProtocol"
           port="8443" maxThreads="200"
           scheme="https" secure="true" SSLEnabled="true"
           clientAuth="false" sslProtocol="TLS"
           keystoreFile="${user.home}/.keystore" keystorePass="test1234"
           />
问题一:keytoolエラー: java.lang.Exception: 鍵ペアは生成されませんでした。別名はすでに存在します 

解决方法: 执行 keytool -delete -alias <别名>

问题二: 运行时异常java.lang.RuntimeException: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target 的处理

根据下面方法生成,导出,导出证书到JRE
1. 删除 %JRE_HOME%/lib/security/cacerts

  1. 生成证书
    keytool -genkey -alias tomcat -keyalg RSA -keystore ~/Documents/keys/tomcat

  2. 导出证书
    keytool -export -file ~/Documents/keys/tomcat.crt -alias tomcat -keystore ~/Documents/keys/tomcat

  3. 导入证书
    sudo keytool -import -keystore /usr/lib/jvm/jdk1.6.0_22/jre/lib/security/cacerts -file ~/Documents/keys/tomcat.crt -alias tomcat

参考:http://steven-wiki.readthedocs.io/en/latest/security/cas-tomcat/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值