參考文獻:http://www.cnblogs.com/beiyan/p/6248187.html html
tomcat默認端口是8080,但想要tomcat支持https,就要配置端口8443。步驟以下:apache
(1)mkdir /etc/tomcat/ssltomcat
cd /etc/tomcat/sslserver
(2)生成Server端證書xml
sudo keytool -genkey -keyalg RSA -dname "cn=wuyameiju.com,ou=none,o=none,l=Beijing,st=Beijing,c=cn" -alias server -keypass tocat -keystore server.keystore -storepass tomcat -validity 3650 htm
(3)生成客戶端證書 blog
sudo keytool -genkey -v -alias client -keyalg RSA -storetype PKCS12 -dname "cn=wuyameiju,ou=none,o=none,l=Beijing,st=Beijing,c=cn" -keypass tomcat -storepass tomcat -keystore client.p12 -validity 3650ssl
(4)讓服務端信任客戶端的證書 it
一、將客戶端證書導出爲一個單獨的CER文件io
sudo keytool -export -alias client -keystore client.p12 -storetype PKCS12 -storepass tomcat -rfc -file client.cer
二、將CER文件導入服務端的證書庫
sudo keytool -import -v -file client.cer -keystore server.keystore
三、查看server.keystore 裏面的證書列表:
sudo keytool -list -keystore server.keystore (證書庫中包含兩個證書,一個是服務端的私鑰,一個是客戶端的可信任公鑰)
(5)讓客戶端信任服務端證書
sudo keytool -keystore server.keystore -export -alias server -file server.cer -validity 36500
(6)修改Tomcat 配置:
vi /etc/tomcat/conf/server.xml
<Connector port="8443" protocol="org.apache.coyote.http11.Http11NioProtocol"
maxThreads="150" SSLEnabled="true" acceptCount="100" clientAuth="false"
disableUploadTimeout="true" enableLookups="false" keystoreFile="/etc/tomcat/ssl/server.keystore" keystorePass="uUqg-5265" scheme="https"
secure="true" sslProtocol="TLS"></Connector>
(7)保存退出:wq
(8)tomcat: sudo /etc/tomcat/bin/shutdown.sh
tomcat: sudo /etc/tomcat/bin/startup.sh (重啓)
(9)w3m https://localhost:8443 (要是看到tomcat首頁說明配置成功!)