JAVA—咖啡館

          ——歡迎訪問rogerfan的博客,常來《JAVA——咖啡館》坐坐,喝杯濃香的咖啡,彼此探討一下JAVA技術,交流工作經驗,分享JAVA帶來的快樂!本網站部分轉載文章,如果有版權問題請與我聯系。

          BlogJava 首頁 新隨筆 聯系 聚合 管理
            447 Posts :: 145 Stories :: 368 Comments :: 0 Trackbacks

          公告

           

          Locations of visitors to this page
          點擊這里給我發消息 點擊這里給我發消息

          常用鏈接

          留言簿(17)

          隨筆分類(542)

          隨筆檔案(438)

          文章分類(182)

          文章檔案(142)

          新聞分類

          ※→ 【JAVA文檔】

          ※→ 【親人博客】

          ※→ 【休閑娛樂】

          ※→ 【友情鏈接】

          ※→ 【學習網站】

          ※→ 【服務網站】

          ※→ 【著名網站】

          ※→ 【阿里博客】

          最新隨筆

          搜索

          積分與排名

          最新評論

          閱讀排行榜

          評論排行榜

          前幾天客戶提出要強制使用HTTPS方式訪問Tomcat中的相關項目,于是研究了下,現將具體的步驟寫下: 

              主要分2步:讓tomcat能使用https--->強制使用https訪問 

          1.讓tomcat能使用https 

            A.在運行命令JAVA_HOME/bin/keytool -genkey -alias tomcat -keyalg  
              RSA  -keystore     C:\Tomcat\GMAE3.0Tomcat\tomcat.keystore 
              這樣就生成了證書,將證書放到合適的地方(任意地方都可以) 

            B.打開tomcat目錄下的server.xml文件并找到關于ssl的相關段 
            
          1    <!-- Define a SSL HTTP/1.1 Connector on port 8443
          2    This connector uses the JSSE configuration, when using APR, the 
          3    connector should be using the OpenSSL style configuration
          4    described in the APR documentation -->
          5    <!--<Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
          6    maxThreads="150" scheme="https" secure="true"
          7    clientAuth="false"  sslProtocol="TLS" />-->
          8    
           
           
            C.去掉注釋,添keystoreFile="C:\Tomcat\GMAE3.0Tomcat\tomcat.keystore" keystorePass="tomcat"的屬性改動完成后配置為:
          1  <Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"   maxThreads="150" scheme="https" secure="true" clientAuth="false" keystoreFile="C:\Tomcat\GMAE3.0Tomcat\tomcat.keystore" keystorePass="tomcat" sslProtocol="TLS" />
          2

            D.然后重啟tomcat就能使用HTTPS訪問 

          2.強制https訪問 

            在tomcat\conf\web.xml中的</welcome-file-list>后面,加上這樣一段: 

           1  <login-config>
           2      <!-- Authorization setting for SSL -->
           3      <auth-method>CLIENT-CERT</auth-method>
           4      <realm-name>Client Cert Users-only Area</realm-name>
           5  </login-config>
           6  <security-constraint>
           7      <!-- Authorization setting for SSL -->
           8      <web-resource-collection >
           9          <web-resource-name >SSL</web-resource-name>
          10          <url-pattern>/*</url-pattern>
          11      </web-resource-collection>
          12      <user-data-constraint>
          13          <transport-guarantee>CONFIDENTIAL</transport-guarantee>
          14      </user-data-constraint>
          15  </security-constraint>
          16

          完成以上步驟后,在瀏覽器中輸入http的訪問地址也會自動轉換為https了
          posted on 2013-06-04 11:29 rogerfan 閱讀(1057) 評論(0)  編輯  收藏

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 孟津县| 白山市| 白城市| 吕梁市| 佛坪县| 忻城县| 民权县| 东宁县| 岐山县| 鲁甸县| 门源| 巴南区| 图片| 木兰县| 铜陵市| 内黄县| 隆尧县| 阜宁县| 北京市| 邯郸县| 香河县| 九寨沟县| 桐乡市| 武夷山市| 襄垣县| 乳源| 遵义市| 长乐市| 宾川县| 忻城县| 安西县| 安化县| 文水县| 湄潭县| 江华| 道真| 灵璧县| 淅川县| 泽库县| 疏勒县| 龙泉市|