標籤:http io ar 使用 sp java for 檔案 on
一、產生認證步驟
二、配置TOMCAT伺服器
(1)修改 $CATALINA_HOME/conf/server.xml 檔案,修改如下:
<Connector port="80" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="443" executor="tomcatThreadPool" enableLookups="false" useBodyEncodingForURI="true" URIEncoding="utf-8" compression="on" compressionMinSize="2048" noCompressionUserAgents="gozilla,traviata" compressableMimeType="text/html,text/xml,text/javascript,text/css,text/plain" />
(2)去掉注釋且修改參數
<Connector port="443" protocol="org.apache.coyote.http11.Http11Protocol" SSLEnabled="true" maxThreads="150" scheme="https" secure="true" clientAuth="want" sslProtocol="TLS" keystoreFile="D:/tomcat.keystore" keystorePass="123456" truststoreFile="D:/tomcat.keystore" truststorePass="123456" />
注釋:keystoreFile、keystorePass、truststoreFile、truststorePass分別是認證檔案的位置和密碼,在認證檔案產生過程中做了設定
(3)修改參數
<Connector port="8009" protocol="AJP/1.3" redirectPort="443" />
(4)強制HTTPS訪問:開啟$CATALINA_HOME/conf/web.xml,或者在專案檔的web.xml最後增加下面內容:
<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後即可以使用SSL。IE地址欄中可以直接輸入地址不必輸入“http://” 或者 “https://” ;也可以輸入 “http:// ” 會跳轉成為 “https://” 來登入。
Tomcat配置https及訪問http自動跳轉至https