我尝试在Java客户端小程序(使用JDK 1.7.0_75-b13构建)和VC ++服务器应用程序之间建立安全套接字连接。
作为测试工具,我使用了在MSDN论坛中找到的VC ++客户端/服务器示例,将其修改为使用SChannel,并且能够使用密码套件TLS_RSA_WITH_AES_128_CBC_SHA建立套接字。它适用于任何TLS 1.0 / 1.1 / 1.2。
当我尝试从Java applet打开套接字到同一服务器应用程序时,连接被拒绝,服务器报告以下内容:
TLS 1.0 AcceptSecurityContext失败:0x80090327
TLS 1.1 AcceptSecurityContext失败:0x80090331
TLS 1.2 AcceptSecurityContext失败:0x80090331
这是用于创建套接字的Java代码:
debugPrint("Setting up secure connection");
SSLSocketFactory sslsocketfactory = (SSLSocketFactory) SSLSocketFactory.getDefault();
SSLSocket sslsocket = (SSLSocket) sslsocketfactory.createSocket("127.0.0.1", socketnumber);
debugPrint("Starting handshake");
sslsocket.setTcpNoDelay(true);
sslsocket.setSoLinger(false, 0);
sslsocket.setKeepAlive(true);
sslsocket.setReuseAddress(true);
sslsocket.setSoTimeout(10000);
sslsocket.setUseClientMode(true);
sslsocket.setWantClientAuth(false);
sslsocket.addHandshakeCompletedListener(new HandshakeCompletedListener()
{
@Override
public void handshakeCompleted(HandshakeCompletedEvent arg0)
{
debugPrint("handshake complete!");
StealthStatus.setServiceConnected(true);
}
});
String cipherSuites[] = sslsocket.getEnabledCipherSuites();
for (int inx=0; inx < cipherSuites.length; inx++)
{
debugPrint("SSL cipher suite supported->" + cipherSuites[inx]);
}
sslsocket.setEnabledCipherSuites(cipherSuites);
sslsocket.startHandshake();
socket = sslsocket;
socketOut = sslsocket.getOutputStream();
socketIn = sslsocket.getInputStream();
运行此命令,对getEnabledCipherSuites的调用将返回列表
TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA
TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA
TLS_RSA_WITH_AES_128_CBC_SHA
TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA
TLS_ECDH_RSA_WITH_AES_128_CBC_SHA
TLS_DHE_RSA_WITH_AES_128_CBC_SHA
TLS_DHE_DSS_WITH_AES_128_CBC_SHA
TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA
TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA
SSL_RSA_WITH_3DES_EDE_CBC_SHA
TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA
TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA
SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA
SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA
TLS_ECDHE_ECDSA_WITH_RC4_128_SHA
TLS_ECDHE_RSA_WITH_RC4_128_SHA
SSL_RSA_WITH_RC4_128_SHA
TLS_ECDH_ECDSA_WITH_RC4_128_SHA
TLS_ECDH_RSA_WITH_RC4_128_SHA
SSL_RSA_WITH_RC4_128_MD5
TLS_EMPTY_RENEGOTIATION_INFO_SCSV
包含所需的TLS_RSA_WITH_AES_128_CBC_SHA并传递给setEnabledCipherSuites。
让VC ++服务器接受来自Java客户端的连接需要什么?
答案 0 :(得分:0)
请参阅:http://docs.oracle.com/javase/7/docs/technotes/guides/security/jsse/ReadDebug.html
在许多情况下,使用-Djavax.net.debug = all标志时生成的日志消息可以引导您朝着正确的方向发展。