主要分爲兩大步:服務端生成配置證書,應用端導入證書。算法
keytool -genkey -keyalg RSA -alias mlongbosso -dname "cn=passport.mlongbo.com" -keystore /home/ndoc/test/cas/mlongbosso.keystore -storepass 123654
說明:指定使用RSA算法,生成別名爲mlongbosso的證書,口令爲123654,證書的DN爲"cn=passport.mlongbo.com" ,這個DN必須同當前主機完整名稱一致!!)
keytool -export -alias mlongbosso -file /home/ndoc/test/cas/mlongbosso.crt -keystore /home/ndoc/test/cas/mlongbosso.keystore -storepass 123654
(註釋:從mlongbosso.keystore中導出別名爲mlongbosso的證書,生成文件mlongbosso.crt)
3. 配置Tomcat的HTTPS服務
keystoreFile屬性值爲mlongbosso.keystore文件路徑, keystorePass屬性值爲證書存貯口令tomcat
<Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true" maxThreads="150" scheme="https" secure="true" clientAuth="false" sslProtocol="TLS" keystoreFile="/home/ndoc/test/cas/mlongbosso.keystore" keystorePass="123654" />
應用端即SSO客戶端.服務器
註釋: Windows下爲%JAVA_HOME%
, Linux下爲$JAVA_HOME
code
keytool -import -alias mlongbosso -file /home/ndoc/test/cas/mlongbosso.crt -keystore $JAVA_HOME/jre/lib/security/cacerts -storepass 123654
keytool -list -keystore $JAVA_HOME/jre/lib/security/cacerts -storepass 123654
注意:若是此處導入失敗,或者要從新導入,須要先刪除%JAVA_HOME%/jre/lib/security/cacerts
文件(刪除前請備份)server
轉自:做者:空谷幽蘭連接:http://www.jianshu.com/p/a1fa19d4ec75來源:簡書著做權歸做者全部。商業轉載請聯繫做者得到受權,非商業轉載請註明出處。