我正在为需要我向代理服务器打开 SSLSocket、进行隧道握手然后在隧道上创建另一个 SSLSocket 的系统编写 Android 客户端。这是我创建隧道的代码:
SSLSocketFactory sslsocketfactory = securityService.getSslContextNoCerts().getSocketFactory();
SSLSocket sslSocket = (SSLSocket) sslsocketfactory.createSocket(proxyAddress.getAddress(),
proxyAddress.getPort());
sslSocket.setEnabledProtocols(new String[] { SecurityService.TLS10 });
sslSocket.setEnabledCipherSuites(SecurityService.CIPHERS);
sslSocket.startHandshake();
然后我进行隧道握手,然后:
SSLSocketFactory sslsocketfactory = securityService.getSslContext().getSocketFactory();
hostSocket = (SSLSocket) sslsocketfactory.createSocket(tunnel,
InetAddress.getByAddress(remoteAddress.getIpAddress()).getHostAddress(),
remoteAddress.getPort(), false);
hostSocket.setUseClientMode(false);
hostSocket.setNeedClientAuth(true);
securityService.setEnabledProtocols(hostSocket);
hostSocket.setEnabledCipherSuites(SecurityService.DATASESSION_CIPHERS);
hostSocket.startHandshake();
此时,我收到带有此消息的 SSLProtocolException:
错误:140760FC:SSL 例程:SSL23_GET_CLIENT_HELLO:未知协议(外部/openssl/ssl/s23_srvr.c:589 0xad12b3f0:0x00000000)
有谁知道我怎么能做到这一点?我知道您的第一个问题是为什么在 SSL 上分层 SSL,但我正在为需要它的现有系统编写客户端。
任何帮助将非常感激。竹斌