Centos下配置tomcat7的https證書


近期搞定了HTTPS配置,特此記錄。

1、把下載的文件拷貝到cert文件夾,然后放在tomcat根目錄下(與conf同一級目錄)。
2、配置conf下的server.xml,修改下面3個節點,如下:

<Connector port="80" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="443" />
<Connector port="443" protocol="HTTP/1.1"
maxThreads="150" SSLEnabled="true" scheme="https" secure="true" 
keystoreFile="cert/your-name.pfx" 
keystoreType="PKCS12" 
keystorePass="you-password"
clientAuth="false" sslProtocol="TLS" />
<Connector port="8009" protocol="AJP/1.3" redirectPort="443" />


3、配置conf下的web.xml,讓http自動跳轉https。在</web-app>前加入下面配置即可。

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

4、在服務器上重啟tomcat的,訪問你的網站。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM