天天看點

使用群輝内置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進行通路了。

繼續閱讀