Windows基于Tomcat构建单双向认证服务

Windows基于Tomcat构建单双向认证服务

1,配置文件:

 tomcat7.0

 tomcat/conf/server.xml

 c:\Windows\System32\driver\etc\hosts 

 -----------------------------------------------

  域名:    127.0.0.1      www.xxx.cn 

  描述:    客户端          服务器

 -----------------------------------------------

 密钥库    client.key.p12     jike.keystore

 证书       client.key.cer    jike.cer

2,生成服务器密钥库以及证书文件:

(1)生成密钥库: ketool -genkey

(2)导出证书文件:keytool -export

 -----------------------------------------------------------------

https>  ketool -genkey(密钥库) -alias(别名) xxx -keyalg(算法) RSA -keystore(

密钥库名)xxx.keystore -validity(有效期) 3650(天)

 ----------------------------------------------------------------

密钥口令

[Unknown]:www.xxx.cn

      SH(城市)

      CN(中国)

3,导出证书:

 https> keytool -export -help

 keytool -export -alias(别名)xxx -keystore(哪个密钥库) xxx.keystore -

 file(导出的文件名)xxx.cer

4,将生成服务器密钥库拷贝到 /bin/apache/conf

 再打开server.xml文件

  在<Connector port="8443"

  keystoreFile="conf/xxx.keystore" keystorePass="123456" />

5,重启服务器 (证书自定义的)

  • 出现错误修改:

服务器验证客户端:

 (1)生成密钥库: ketool -genkey

 (2)导出证书文件:keytool -export

(3)将客户端证书导入服务器密钥库信任链  keytool -import

 https>  ketool -genkey(密钥库) -alias(别名) xxx(client) -keyalg(算法) RSA 
  -storetype(密钥库名)PKCS12 -keystore client.key.p12

123456

client

SH

CN

导出证书:

 https> keytool -export -help

  keytool -export -keystore(哪个密钥库) xxx.key.p12 -storetype PKC12

  -alias client -file client.key.cer

将该证书导入信任链中:

 keytool -import -help

 keytool -import -file client.key.cer -keystore xxx.keystore -v

-------------- 双向认证 ------------------------------------------------

$$$-----再次执行 【 步骤4 】与【 步骤5 】

4,将生成服务器密钥库拷贝到 /bin/apache/conf

  再打开server.xml文件

在<Connector port="8443" clientAuth="true"启用双向认证

  keystoreFile="conf/xxx.keystore" keystorePass="123456"

  truststoreFile="conf/xxx.keystore" truststorePass="123456"/>

5,重启服务器 (证书自定义的)

猜你喜欢

转载自blog.csdn.net/gaokcl/article/details/81566627