tomcat7支持https配置


基本環境:centos7.0   jdk1.8  tomcat7

1.下載tomcat,解壓到指定目錄
例如:/home/test/apache-tomcat-7.0.81
2.生成證書
 首先進入JAVA_HOME的bin目錄下輸入如下代碼:
      cd /usr/java/jdk1.8.0_121/bin/
      keytool -genkey -alias tomcat -keyalg RSA -keystore /home/test/apache-tomcat-7.0.81/tomcat.keystore -validity 36500 
/home/test/apache-tomcat-7.0.81/tomcat.keystore 指定證書的保存路徑,后續配置會使用)
  Enter keystore password: #此處需要輸入大於或等於6個字符的字符串
      Re-enter new password:
      What is your first and last name? #“您的名字與姓氏是什么?”這是必填項, 
      [Unknown]: haha
      What is the name of your organizational unit? #“你的組織單位名稱是什么?”可以按照需要填寫也可以不填寫直接回車,實驗中直接回車
      [Unknown]:
      What is the name of your organization? #“您的組織名稱是什么?”,同上直接回車
      [Unknown]:
      What is the name of your City or Locality? #“您所在城市或區域名稱是什么?同上直接回車
      [Unknown]:
      What is the name of your State or Province? #“您所在的州或者省份名稱是什么?”
      [Unknown]:
  What is the two-letter country code for this unit? #“該單位的兩字母國家代碼是什么?”
      [Unknown]:
      Is CN=10.15.24.254, OU=Unknown, O=Unknown, L=Unknown, ST=Unknown, C=Unknown correct? #系統詢問“正確 嗎?”時,對照    輸入信息,如果符合要求則使用鍵盤輸入字母“y”,否則輸入“n”重新填寫上面的信息
  [no]: y
      Enter key password for
      RETURN if same as keystore password): #輸入的主密碼,這項較為重要,會在tomcat配置文件中使用,建議輸入與keystore的密碼一致,設置其它密碼也可以
      Re-enter new password:
 
3.修改tomcat的server.xml配置文件,使其支持https
  cd /home/test/apache-tomcat-7.0.81
     vi config/server.xml
 增加https的節點配置,https的配置默認是被注釋的,取消注釋,然后指定生成的keystore證書文件路徑和證書秘鑰
 
4.開啟8443端口
 vim /etc/sysconfig/iptables 進入端口設置文件編輯狀態,添加一行
 
重啟防火牆
systemctl restart firewalld.service
 
5.重啟tomcat,在瀏覽器輸入https://ip:8443 驗證即可


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM