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 閱讀(1060) 評論(0)  編輯  收藏

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


          網站導航:
           
          主站蜘蛛池模板: 南和县| 航空| 黔江区| 密云县| 新和县| 虞城县| 黔西| 肥乡县| 上犹县| 青川县| 怀柔区| 鱼台县| 阜康市| 齐齐哈尔市| 马尔康县| 亚东县| 彭阳县| 历史| 通河县| 乌海市| 藁城市| 唐海县| 隆昌县| 长汀县| 喀喇| 鹤壁市| 芷江| 廉江市| 屯留县| 应城市| 稷山县| 平远县| 关岭| 睢宁县| 长宁县| 静海县| 乌拉特中旗| 武安市| 抚顺县| 常山县| 桓台县|