Java web加密之将应用从http换成https的方法

感谢文章http://blog.csdn.net/zhangzuomian/article/details/50324395 

 但未测试过,先记录下

大致分2步:1、获取证书。2、修改tomcat的config/server.xml和项目中web.xml配置

打开config/server.xml,取消下面8443端口代码的注释,并修改如下:

<Connector port="8443"protocol="HTTP/1.1" SSLEnabled="true"     maxThreads="150" scheme="https" secure="true"     
  clientAuth="false"keystoreFile="D:/AppServer/Tomcat/apache-tomcat-6.0.32/conf/tomcat.keystore"     
  keystorePass="deleiguo" sslProtocol="TLS" />   

  注:
keystoreFile:证书文件的位置,keystorePass 是keystore的密码(你在生成证书的时候,会有的keystore密码和tomcat主密码)

项目中web.xml添加如下:、

<security-constraint>   
       <web-resource-collection>   
              <web-resource-name>SSL</web-resource-name>   
              <url-pattern>/*</url-pattern>   
       </web-resource-collection>  
  
       <user-data-constraint>   
              <transport-guarantee>CONFIDENTIAL</transport-guarantee>   
       </user-data-constraint>   
</security-constraint>  

  转载自http://blog.csdn.net/rainyspring4540/article/details/68925073

原文地址:https://www.cnblogs.com/yangyang2018/p/8421453.html