天天看点

使用群辉内置tomcat配置https访问和配置ssl

第一步,你得有一个SSL证书,我这里使用的是阿里云申请到的免费型DV证书,进入阿里云SSL应用,下载已经签发的证书,证书类型请选择tomcat。

使用群辉内置tomcat配置https访问和配置ssl

第二步,打开WinSCP(软件自己到百度搜索,有一大堆下载链接,不过要使用winscp必须要获得群辉的root权限),ssh进入到群辉的根目录,找到tomcat的配置文件server.xml和web.xml,文件的路径地址为volume1>@appstore>Tomcat7>src>conf,在src文件下新建一个文件夹,名字随意,我这里取名ssl,是用于存放SSL证书的。

使用群辉内置tomcat配置https访问和配置ssl

第三步,打开server.xml,找到

<!--
 <Connector port="8443" protocol="org.apache.coyote.http11.Http11Protocol"
               maxThreads="150" SSLEnabled="true" scheme="https" secure="true"
               clientAuth="false" sslProtocol="TLS" />
-->
           
使用群辉内置tomcat配置https访问和配置ssl

去掉注释,添加keystoreFile=“ssl/证书” keystorePass=“密码”,其中,ssl是你在第二步中新建的文件夹,记得放入你的证书。

<Connector port="8443" protocol="org.apache.coyote.http11.Http11Protocol"
               maxThreads="150" SSLEnabled="true" scheme="https" secure="true"
               keystoreFile="ssl/证书" keystorePass="密码"
               clientAuth="false" sslProtocol="TLS" />
           
使用群辉内置tomcat配置https访问和配置ssl

第四步,修改web.xml,搜索,在后面添加以下内容,这是为了使tomcat能够强制进入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> 
           
使用群辉内置tomcat配置https访问和配置ssl

第五步,把修改好的server.xml和web.xml放回原处覆盖掉,重启tomcat,就可以使用https进行访问了。

继续阅读