配置 Tomcat 使用 https 協議
一、生成證書
使用jdk 自帶工具keytool 生成證書
[[email protected] ~]# keytool -genkeypair-alias "tomcat" -keyalg "RSA" -keystore"/usr/local/src/apache-tomcat-7.0.72/ssl/192.168.10.61.keystore"
Enter keystore password: 輸入密碼
Re-enter new password:
What is your first and last name? 這裏輸入的名字應該與域名保持一致,否則道中無法訪問
[Unknown]: 192.168.10.61
What is the name of your organizationalunit? 輸入組織信息
[Unknown]: 192.168.10.61
What is the name of your organization? 輸入組織信息
[Unknown]: 192.168.10.61
What is the name of your City or Locality? 輸入城市名稱
[Unknown]: suzhou
What is the name of your State or Province?輸入省份名稱
[Unknown]: jiangsu
What is the two-letter country code forthis unit? 輸入組織編碼
[Unknown]: cn
Is CN=192.168.10.61, OU=192.168.10.61,O=192.168.10.61, L=suzhou, ST=jiangsu, C=cn correct?
[no]: y 確認組織信息 ,確認輸入yes
Enter key password for <tomcat>
(RETURNif same as keystore password):
Re-enter new password: # 輸入設置證書設置的密碼
備註:演示設置的密碼為123123
二、修改server.xml 配置文件
改下面的代碼
87 <Connector port="8443" protocol="org.apache.coyote.http11.Http11Protocol" 88 maxThreads="150" SSLEnabled="true" scheme="https" secure="true" 89 clientAuth="false" sslProtocol="TLS" /> 90 -->
為
87 <Connector port="8443" protocol="org.apache.coyote.http11.Http11Protocol" 88 maxThreads="150" SSLEnabled="true" scheme="https" secure="true" 89 clientAuth="false" sslProtocol="TLS" 90 keystoreFile="/usr/local/src/apache-tomcat-7.0.72/ssl/192.168.10.61.keystore" 91 keystorePass="123123"/> 92 93 94 <!-- Define an AJP 1.3 Connector on port 8009 --> 95 <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
三、啟動tomcat
./bin/startup.sh
四、測試
在瀏覽器中輸入訪問地址 https://192.168.10.61:8443/
添加瀏覽器安全例外,即可訪問(備註:瀏覽器 flash 插件版本低,在這裏就無法截圖上傳了)
本文出自 “sdsca” 博客,請務必保留此出處http://sdsca.blog.51cto.com/10852974/1972712
配置 Tomcat 使用 https 協議