在局域網內實現https安全訪問


在局域網內實現https安全訪問

准備原料

服務器 resin (當然也可以是tomcat,這里以resin為例)

安裝jdk

域名 (隨便寫一個就行,因為是內網使用,不會被校驗)

生成證書

  • 第一步:為服務器生成證書

keytool -genkey -alias resin -keypass 123456 -keyalg RSA -keysize 1024 -validity 365 -keystore D:/keys/resin.keystore -storepass 123456

  • 第二步:為客戶端生成證書

keytool -genkey -alias client1 -keypass 123456 -keyalg RSA -keysize 1024 -validity 365 -storetype PKCS12 -keystore D:/keys/client1.p12 -storepass 123456

  • 第三步:讓服務器信任客戶端證書

keytool -export -alias client1 -keystore D:/keys/client1.p12 -storetype PKCS12 -keypass 123456 -file D:/keys/client1.cer

keytool -import -v -file D:/keys/client1.cer -keystore D:/keys/resin.keystore -storepass 123456

  • 第四步:讓客戶端信任服務器證書

keytool -list -v -keystore D:/keys/resin.keystore

keytool -keystore D:/keys/resin.keystore -export -alias resin -file D:/keys/server.cer

注意:當提示:您的名字與姓氏是什么? 請輸入你准備的域名比如:www.aclululu.com

 

 

其他的按照提示輸入就是了,最后會得到四個文件如下:

 

生成客戶端安裝證書

  • 雙擊server.cer文件,按默認安裝,直到安裝成功

  • 打開IE瀏覽器,找到證書

     

     

     
  • 選擇導出,導出的證書即可用於其他客戶進行安裝使用。這里命名為aclululu_client

配置服務器端resin

早期的版本,因為沒有最新的,所以請見諒!
resin.conf文件具體需要修改的地方

  • 配置https證書
<http address="*" port="443"> 
  <jsse-ssl> <key-store-type>jks</key-store-type> <key-store-file>keys/resin.keystore</key-store-file> <password>123456</password> </jsse-ssl> </http> 
  • 配置更新
<session-config> 
  <session-timeout>-1</session-timeout> <enable-url-rewriting>false</enable-url-rewriting> <reuse-session-id>false</reuse-session-id> <cookie-secure >true</cookie-secure> </session-config> 
  • 配置httpOnly請求

<cookie-http-only>true</cookie-http-only>

  • 配置secure屬性

<secure>true</secure>

客戶機安裝證書,修改host文件(注意客戶機)

打開IE瀏覽器,導入證書

 

按照默認導入剛剛保存的aclululu_client證書。直到導入成功。

 
 

修改host文件

假如服務器的ip為:172.16.1.123
方法一:
修改批處理文件:aclululu_host.bat

@echo off
color 0F
@attrib -r "%windir%\system32\drivers\etc\hosts"
@echo= >>"%windir%\system32\drivers\etc\hosts"
@echo= >>"%windir%\system32\drivers\etc\hosts"
@echo #Fssoft Start >>"%windir%\system32\drivers\etc\hosts"
@echo 172.16.1.123 www.aclululu.com>>"%windir%\system32\drivers\etc\hosts"
@echo #Fssoft End >>"%windir%\system32\drivers\etc\hosts"
@echo= >>"%windir%\system32\drivers\etc\hosts"
@echo= >>"%windir%\system32\drivers\etc\hosts"
@attrib +r "%windir%\system32\drivers\etc\hosts"

然后雙擊執行bat即可

方法二:
直接去
C:\Windows\System32\drivers\etc下手動修改


 

訪問

https
就可以安全訪問172.16.1.123這台主機上的網頁了

原文鏈接:https://www.jianshu.com/p/631719c9f0c6


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM