tomcat安装ssl

1 篇文章 0 订阅

如果你想讲http服务升级为https,那么你需要安装ssl,这个东西你可以在腾讯云上安装免费ssl证书,首先你要有账号,

申请后就可以下载证书了

下载后

二、配置server.xml(标记的都是需要修改的)

redirectport是重定向端口,是为了将http转为https服务的端口,我这里改了默认端口,因为https端口已经被另外一个程序占用,

所以改成了7443。

代码

    <Connector port="8180" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="7443" />
    <!-- A "Connector" using the shared thread pool-->
    <!--
    <Connector executor="tomcatThreadPool"
               port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />
    -->
    <!-- Define a SSL HTTP/1.1 Connector on port 8443
         This connector uses the JSSE configuration, when using APR, the
         connector should be using the OpenSSL style configuration
         described in the APR documentation -->
    
    <Connector port="7443" protocol="HTTP/1.1" SSLEnabled="true"
               maxThreads="150" scheme="https" secure="true"
               keystoreFile="conf/ssl/www.frhis.club.jks"
               keystorePass="ug8e38y57r85b"
               clientAuth="false" sslProtocol="TLS" />
    

    <!-- Define an AJP 1.3 Connector on port 8009 -->
    <Connector port="8109" protocol="AJP/1.3" redirectPort="7443" />

文件位置

三、配置web.xml

<login-config>
    <!-- Authorization setting for SSL -->
    <auth-method>CLIENT-CERT</auth-method>
    <realm-name>Client Cert Users-only Area</realm-name>
</login-config>
<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>

这段代码放到web.xml中

写到这里就可以了

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值