加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 创业 > C语言 > 正文

阿里云配置tomcat https

发布时间:2020-12-15 03:18:22 所属栏目:C语言 来源:网络整理
导读:阿里云申请免费的SSL证书和配置https,可参考该篇博文:https://blog.csdn.net/baidu_19473529/article/details/70037976 虽然有现成的,不过我还是要做一个小小的总结记录一下。 由于我公司使用的tomcat主要是8.5,所以我以8.5配置作为讲解(总的来说,配置相

阿里云申请免费的SSL证书和配置https,可参考该篇博文:https://blog.csdn.net/baidu_19473529/article/details/70037976

虽然有现成的,不过我还是要做一个小小的总结记录一下。

由于我公司使用的tomcat主要是8.5,所以我以8.5配置作为讲解(总的来说,配置相差不大)

假定你已经在阿里云成功申请到免费的SSL证书,现在我们开始来配置。

1.首先讲pfx文件放在tomcat的一个叫cert的文件夹(tomcat实际上没有这个文件夹,你可以选择手动创建一个)

cd tomcat8
mkdir cert

2.修改server.xml

<Connector port="443" protocol=org.apache.coyote.http11.Http11NioProtocol"
               maxThreads=150" SSLEnabled=true"  scheme=https
    secure="
               >
        <SSLHostConfig>
             <Certificate certificateKeystoreFile=cert/test.pfx
                         certificateKeystoreType=PKCS12" certificateKeystorePassword=1541231341210" />
        </SSLHostConfig>
    </Connector>


 <Connector port=80HTTP/1.1
               connectionTimeout=20000
               redirectPort=" />

 <Connector port=8009AJP/1.3" redirectPort=" />

?

3.修改web.xml

编辑web.xml,不加下面这段的话不能把http请求转为https
在该文件标签(一般在文件最末尾)后面加上这样一段:

<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>

本文主要参考该篇博文Tomcat8、9配置https SSL证书 阿里云的免费dv证书

另外为了调试方便,本地tomcat还需配置https,关于windowns配置https,可参考该篇博文本地windows搭建https

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读