相互SSL身份验证失败

时间:2018-08-01 16:58:50

标签: tomcat ssl cxf mutual-authentication

我正在尝试连接到受相互身份验证保护的Web服务。

我正在使用cxf Web客户端,并且客户端的配置如下所示

      KeyStore keyStore = KeyStore.getInstance("JKS");
      KeyStore trustStore = KeyStore.getInstance("JKS");
      String keystorepass = "***";
      String trustpass = "***";
      File truststore = new File("trustfile");
      File keystoreFile = new File("keyfile");
      keyStore.load(new FileInputStream(keystoreFile), keystorepass.toCharArray());
      trustStore.load(new FileInputStream(truststore), trustpass.toCharArray());

      tlsParams.setDisableCNCheck(true);
      tlsParams.setSecureSocketProtocol("TLSv1.2");
      TrustManagerFactory trustFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
      trustFactory.init(trustStore);
      TrustManager[] tm = trustFactory.getTrustManagers();
      tlsParams.setTrustManagers(tm);
      KeyManagerFactory keyFactory = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
      keyFactory.init(keyStore, keystorepass.toCharArray());
      KeyManager[] km = keyFactory.getKeyManagers();
      tlsParams.setKeyManagers(km);
      FiltersType filter = new FiltersType();
      filter.getInclude().add(".*_WITH_AES_.*");
      filter.getExclude().add(".*_DH_anon_.*");
      tlsParams.setCipherSuitesFilter(filter);

实际将消息发送到服务器的Web客户端代码如下

 WebClient client = WebClient.create(tallyEndPoint);
client.path(partnerAuthUrl);
ClientConfiguration config = WebClient.getConfig(client);
config.getInInterceptors().add(new LoggingInInterceptor());
config.getOutInterceptors().add(new LoggingOutInterceptor());
HTTPConduit conduit =
    (HTTPConduit) WebClient.getConfig(client).getConduit();
HTTPClientPolicy policy = conduit.getClient();
policy.setProxyServer(proxyUrl);
policy.setProxyServerPort(proxyPort);
conduit.setTlsClientParameters(tlsParams);    
MultivaluedMap<String, String> formParams = new MultivaluedHashMap<>();
formParams.add("***", "***");
Form postForm = new Form(formParams);
client.type(MediaType.APPLICATION_FORM_URLENCODED_TYPE);
Response response = client.form(postForm);enter code here

从服务器端数据包捕获中可以看到以下消息

  • 客户端问候-141 * 192。* 10。*** TLSv1.2 414客户端问候
  • 服务器确认
  • 服务器问候143 * 10。* 198。*** TLSv1.2 1575服务器问候
  • 服务器确认
  • 服务器证书,密钥交换和证书请求-145 * 10。* 198。*** TLSv1.2 1267证书,服务器密钥交换,证书请求,服务器Hello完成
  • 客户确认
  • 客户确认
  • 客户端重置确认148 **** 198. * 10。* TCP 115 58308→443 [RST,ACK] Seq = 288 Ack = 4037 Win = 65535 Len = 0

我已在客户端中启用SSL调试,并且看到正在记录证书更改消息

我可以看到正在发生的动作

  • ClientHello,TLSv1.2
  • ServerHello,TLSv1.2
  • 证书链
  • ECDH ServerKeyExchange
  • ServerHelloDone
  • ECDHClientKeyExchange
  • ClientHello,TLSv1.2

最后一个客户之后你好,我被断开了连接

  

tomcat-http--1,写:TLSv1.2握手,长度= 282

     

tomcat-http--1,处理异常:java.net.SocketException:连接重置

     

tomcat-http--1,发送TLSv1.2警报:致命,描述=意外消息

     

tomcat-http--1,写:TLSv1.2警报,长度= 2

     

tomcat-http--1,异常发送警报:java.net.SocketException:管道损坏

     

tomcat-http--1,称为closeSocket()

     

tomcat-http--1,写:TLSv1.2应用程序数据,长度= 472

     

tomcat-http--1,称为close()

     

tomcat-http--1,称为closeInternal(true)

     

tomcat-http--1,发送TLSv1.2警报:警告,说明= close_notify

     

tomcat-http--1,写:TLSv1.2警报,长度= 26

     

tomcat-http--1,称为closeSocket(true)

我确实拥有带有我的私钥的密钥库和一个添加并配置了服务器密钥链的信任库。

任何帮助都会得到极大的帮助

0 个答案:

没有答案
相关问题