Centos下配置tomcat7的https證書

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

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

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


三、配置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> 

四、在服務器上重啓tomcat的,訪問你的網站。app

相關文章
相關標籤/搜索