使用https协议访问web应用
1.下载安装tomcat7
2.使用JDK keytool 生成keystore
3.到处相应的cer证书文件
4.修改/conf/server.xml
5.浏览器导入证书
使用命令:keytool -genkeypair -alias “tomcat” -keyalg “RSA” -keystore “e:\tomcat.keystore”
#使用 keytool -genkeypair -help 获取 genkeypair的用法。
#命令生产一对非对称密钥和自我签名的证书保存到 e:\tomcat.keystore文件中
使用命令从 KEYSTORE中导出一个证书文件:
keytool -export -alias tomcat -keystore e:\tomcat.keystore -rfc -file tomcat.cer
#”-rfc” 表示以base64输出文件,否则以二进制输出
修改tomcat /conf/server.xml文件
去掉注释 ‘<!– –>’
<Connector port="443"protocol="org.apache.coyote.http11.Http11Protocol"
maxThreads="150" SSLEnabled="true" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS"
keystoreFile="E\tomcat.keystore"
keystorePass="123456"/>
修改端口号
添加keystoreFile 和 keystorePass
运行tomcat服务器,访问https://localhost
(https默认443)
浏览器导入证书