把Tomcat的http改为https的步骤、方法

第一:
打开命令符输入:keytool -genkey -alias tomcat -keyalg RSA -keystore D:\\a.keystore
输入密码:111111
姓氏:hhl
区域名称: china
国家/地区代码:cn
是否正确:     y
其它不用填写;然后在D盘会有a.keystore的文件,这就是证书配置文件
第二:
打开tomcat的conf目录的server.xml文件,添加以下内容:
[html]  view plain  copy
  1. <Connector port="8443" protocol="org.apache.coyote.http11.Http11NioProtocol" SSLEnabled="true"    
  2.               maxThreads="150" scheme="https" secure="true"    
  3.               clientAuth="false" sslProtocol="TLS"     
  4.        keystoreFile="D:\a.keystore"    
  5.        keystorePass="123456" />    
打开tomcat的conf目录的web.xml文件,添加以下内容:
[html]  view plain  copy
  1. <security-constraint>      
  2.     <web-resource-collection >      
  3.         <web-resource-name>SSL</web-resource-name>      
  4.         <url-pattern>/*</url-pattern>      
  5.     </web-resource-collection>      
  6.     <user-data-constraint>      
  7.         <transport-guarantee>CONFIDENTIAL</transport-guarantee>      
  8.     </user-data-constraint>      
  9. </security-constraint>   
运行Tomcat即可测试

猜你喜欢

转载自blog.csdn.net/qq_25293281/article/details/80415862
今日推荐