2015-12-10 87 views
1

我正在使用Apache Mina(Mina2 - Netty不可用 - 不要问为什么:P)创建一个通过TLS连接到TCP服务器的TCP客户端。Apache Mina TLS客户端 - 骆驼

这里的的SSLContext:

这里是我的蓝图XML路线:

<route id="ReadMQ"> 
     <from uri="jmsep://topic:test/014/data" /> 
     <process ref="readIt"></process> 
     <to 
      uri="mina2:tcp://SOMEHOST:38332?sync=true;sslContextParameters=#mySSL;minaLogger=true" /> 

    </route> 

cert.pem同时包含密钥和证书在里面。

当妮娜尝试连接到端点,因此它的服务器关闭与此错误的连接:

  System.IO.IOException: The handshake failed due to an unexpected  packet format. 
         at System.Net.Security.SslState.StartReadFrame(Byte[] buffer, Int32 readBytes, AsyncProtocolRequest asyncRequest) 

望着错误,那感觉就像米娜没有用正确的协议连接?

这里的米娜说什么:

  SEVERE: Exception on receiving message from address:  SOMEHOST:38332 using connector: (nio socket connector: managedSessionCount: 0) 
      Throwable occurred: java.io.IOException: An existing connection  was forcibly closed by the remote host. 

此外,当我使用的s_client.First这样: 的OpenSSL的s_client.First -connect,某:38332 -cert cert.pem - 键cert.pem -state -debug

它开始并通过交换证书进行SSL握手。

任何线索我在这里失踪?

回答

0

密钥库和进入信任库的证书没有被添加,因为它们是PEM格式。服务器将请求客户端证书,客户端的证书链将为空,因此会出现错误。 为了解决这个问题,我创建了一个JKS格式的密钥库,并导入了p12文件(使用pem文件创建)并且工作。