1.申請ssl證書html
2.下載ssl證書 打開此網址 https://myssl.com/cert_convert.html 將證書文件(xxx.com.crt)和密鑰文件上傳(xxx.com.key) 輸入密碼後會獲得一個jks的文件。上傳到你的tomcat的conf文件夾下便可。web
3.修改server.xmlapache
這是tomcat原樣字段 <Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" /> 修改成下面這樣的 <Connector port="80" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="443" />
<Connector port="8443" protocol="org.apache.coyote.http11.Http11Protocol" maxThreads="150" SSLEnabled="true" scheme="https" secure="true" clientAuth="false" sslProtocol="TLS" /> --> //上面這部分是server.xml中原樣的字段 <Connector port="443" protocol="HTTP/1.1" SSLEnabled="true" maxThreads="150" scheme="https" secure="true" keystoreFile="conf/xxxxxx.com.jks" //這裏是你的jks的路徑若是你是放在conf下 修改文件名便可。 keystorePass="123456" //這是你在前面網站上設定的密碼 clientAuth="false" sslProtocol="TLS" />
4.修改web.xmltomcat
在web.xml最後粘貼這段代碼。位置在<welcome-file-list>節點下面網站
<!-- SSL證書配置添加以下 --> <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>
5.重啓tomcat,是重啓!!!!!!!!!!!!!url
6.若是仍是不能夠,檢查本身是否安裝了ssl相關的模塊。spa