或
2. 如果Tomcat报异常,上面的办法太麻烦,下面有一个简单的方法;
Failed to initialize end point associated with ProtocolHandler ["http-apr-8443"] java.lang.Exception: Connector attribute SSLCertificateFile must be defined when using SSL with APR
=====================================================
总结:
1. 生成Key
在
%CATALINE_HOME%/keys路径下执行如下命令:
%CATALINE_HOME%/keys > keytool -genkey -alias sucre.cn.key -keyalg RSA -keystore ./sucre.cn.key
...
... 填写一堆信息和key的口令,名字与姓氏填你的域名,否则CAS登陆成功,不会返回到你的站点,所以如果你有不同的站点,就要设置多个证书
...
# 根据key导出证书
%CATALINE_HOME%/keys > keytool -export -file ./sucre.cn.key.crt -alias sucre.cn.key -keystore ./sucre.cn.key
# 将证书导入到jre
%CATALINE_HOME%/keys > keytool -import -keystore %JAVA_HOME%\jre\lib\security\cacerts -file .\sucre.cn.key.crt -alias sucre.cn.key
...
... Jre的默认密钥库口令为:changeit
...
2. 打开8443端口
修改%CATALINE_HOME%/conf/server.xml,
<Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
maxThreads="150" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS" keystoreFile="%CATALINE_HOME%/keys/key文件" keystorePass="你设置的key的口令" />
注意上面是key文件,不是证书文件;
3. 运行TOMCAT,如果报错,尝试注释掉:
<Listener SSLEngine="on" className="org.apache.catalina.core.AprLifecycleListener"/>