為父母生,為老婆死,為程序奮斗一輩子,吃眼前虧,上公司的當,最后死在客戶的需求上

          Hector_封嘴

          華子說:看破紅塵,與程序為伴!
          posts - 4, comments - 1, trackbacks - 0, articles - 1
            BlogJava :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理
          1. 讓 tomcat 能使用 https
            A. 在運行命令 JAVA_HOME/bin/keytool -genkey -alias tomcat -keyalg RSA  -keystore     C:/Tomcat /GMAE3.0Tomcat/tomcat .keystore 這樣就生成了密鑰庫,將密鑰庫放到合適的地方(任意地方都可以)
            B. 打開 tomcat 目錄下的 server.xml 文件并找到關(guān)于 ssl 的相關(guān)段 
              <!-- Define a SSL HTTP/1.1 Connector on port 8443 -->
              
          <!--
              <Connector port="8443" maxHttpHeaderSize="8192"
                         maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
                         enableLookups="false" disableUploadTimeout="true"
                         acceptCount="100" scheme="https" secure="true"
                         clientAuth="false" sslProtocol="TLS" />
              
          -->
            C. 去掉注釋,添 keystoreFile="C:/Tomcat /GMAE3.0Tomcat/tomcat .keystore"  keystorePass="tomcat " 的屬性,改動完成后配置為 :
          <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"  /> 
            D. 然后重啟tomcat就能使用HTTPS訪問
          2. 強制 https 訪問
            在 tomcat /conf/web.xml 中的 </welcome- file-list> 后面加上這
              <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> 
          完成以上步驟后,在瀏覽器中輸入http的訪問地址也會自動轉(zhuǎn)換為https了

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


          網(wǎng)站導航:
           
          用兩年的工作經(jīng)驗,從零開始,重新開始做一個稱職的程序員!
          主站蜘蛛池模板: 邵阳市| 巴中市| 寿阳县| 浏阳市| 阳谷县| 巴楚县| 英山县| 青海省| 陵川县| 南丹县| 武威市| 临清市| 肇庆市| 那坡县| 宜宾市| 成都市| 马关县| 乐山市| 荔浦县| 隆安县| 永吉县| 朝阳市| 清徐县| 博湖县| 永德县| 兴城市| 合山市| 西藏| 桂东县| 固安县| 宁强县| 双鸭山市| 乌苏市| 东阳市| 巴彦县| 扶沟县| 密云县| 额济纳旗| 通许县| 惠东县| 湘潭县|