cas 单点登陆实战-sso-config篇(四)

本篇章继续讲解写cas时遇到的坑------证书生成。

在window下的证书生成,在linxu下的cas证书生成,证书用域名,证书用ip

纠正一点,网上说的cas证书生成只能用域名是错误的。也是可以用ip的,亲测有效。

1.在windows下的证书生成(域名)

注意:CN=域名,我们采用passport.sso.com

keytool -genkeypair -keyalg RSA -keysize 2048 -sigalg SHA1withRSA -validity 36500 -alias passport.sso.com -keystore d:/tomcat.keystore -dname "CN=passport.sso.com,OU=kawhi,O=carl,L=GuangZhou,ST=GuangDong,C=CN"

输入上述命令,下面密码我们输入changeit,然后一直回车,就在d盘生成了tomcat.keystore文件;

在cmd下输入如下命令,密码为上面输入的changeit:keytool -exportcert -alias passport.sso.com -keystore d:/tomcat.keystore -file d:/tomcat.cer -rfc

输入密码为 changeit并同意导入:keytool -import -alias passport.sso.com -keystore %JAVA_HOME%\jre\lib\security\cacerts -file d:/tomcat.cer -trustcacerts

2.在linxu下的证书生成(域名)

其实和在windows上的一样,只需要改一下地址就可以了。进入你服务器上的jdk的bin目录,之后执行上述步骤就可以了。

3.在linxu或者windows下的证书生成(ip)

keytool -genkeypair -keyalg RSA -keysize 2048 -sigalg SHA1withRSA -validity 36500 -alias 172.17.1.10 -keystore /opt/jdk1.8.0_151/bin/tomcat.keystore -dname "CN=172.17.1.10,OU=kawhi,O=carl,L=GuangZhou,ST=GuangDong,C=CN" -ext san=ip:172.17.1.10


keytool -exportcert -alias 172.17.1.10 -keystore /opt/jdk1.8.0_151/bin/tomcat.keystore  -file /opt/jdk1.8.0_151/bin/tomcat.cer -rfc


keytool -import -alias 172.17.1.10 -keystore /opt/jdk1.8.0_151/jre/lib/security/cacerts -file /opt/jdk1.8.0_151/bin/tomcat.cer -trustcacerts

发现了吗?其实只是在第一句证书后加上了-ext san=ip:172.17.1.10这个而已,问题就可以解决了。

猜你喜欢

转载自blog.csdn.net/qq_36666181/article/details/81907332