tomcat 配置https + 数字证书认证

生成服务端证书
keytool -genkey -alias tomcat -keypass 123456 -keyalg RSA -keysize 1024 -validity 365 -keystore D:/keys/tomcat.keystore -storepass 123456
客户端证书
keytool -genkey -alias client -keypass 123456 -keyalg RSA -keysize 1024 -validity 365 -storetype PKCS12 -keystore D:/keys/client.p12 -storepass 123456
客户端证书导出为一个单独的CER文件
keytool -export -alias client -keystore D:/keys/client.p12 -storetype PKCS12 -keypass 123456 -file D:/keys/client.cer
服务端添加客户端信任
keytool -import -v -file D:/keys/client.cer -keystore D:/keys/tomcat.keystore
查看证书内容
keytool -list -v -keystore D:/keys/tomcat.keystore
导出服务端公钥
keytool -keystore D:/keys/tomcat.keystore -export -alias tomcat -file D:/keys/server.cer

<Connector  
port="8443"
protocol="org.apache.coyote.http11.Http11NioProtocol" 
SSLEnabled="true"
maxThreads="150"
scheme="https"
secure="true"
clientAuth="true"
sslProtocol="TLS"
keystoreFile="D:/keys/tomcat.keystore"
keystorePass="123456"
truststoreFile="D:/keys/tomcat.keystore"
truststorePass="123456" />

</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>
 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值