tomcat配置https证书

来源:互联网 发布:中国金融交易所数据 编辑:程序博客网 时间:2024/05/20 15:11


tomcat7/tomcat8配置https证书

1、在tomcat根目录下新建cert目录,存放证书文件

2、打开tomcat配置文件:conf/server.xml

修改8443端口为443,然后添加配置https证书如下

<Connector port="443"protocol="org.apache.coyote.http11.Http11Protocol"

               maxThreads="150"SSLEnabled="true"scheme="https"secure="true" 

                           keystoreFile="cert/xxx.pfx" //这里是证书文件

                           keystorePass="xxx" //这里时证书密码

                           keystoreType="PKCS12"

               clientAuth="false"sslProtocol="TLS" />


3、让访问http时自动跳转到https,打开web.xml添加

<security-constraint>  
    <!-- Authorization setting for SSL -->  
    <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> 

原创粉丝点击