在局域网内实现https安全访问

在局域网内实现https安全访问

准备原料

服务器 resin (固然也能够是tomcat,这里以resin为例)浏览器

安装jdktomcat

域名 (随便写一个就行,由于是内网使用,不会被校验)安全

生成证书

  • 第一步:为服务器生成证书

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 123456cookie

  • 第三步:让服务器信任客户端证书

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

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

  • 第四步:让客户端信任服务器证书

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

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

注意:当提示:您的名字与姓氏是什么? 请输入你准备的域名好比:www.aclululu.comcode

 

 

其余的按照提示输入就是了,最后会获得四个文件以下:

 

生成客户端安装证书

  • 双击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

相关文章
相关标签/搜索