我想通过tls进行沟通。 tls握手工作,之后,服务器端应启动http服务器并与http客户端通信。 即时通讯使用灰熊网络服务器,但我不知道如何使用我建立的tls安全连接。使用GrizzlyServerFactory,我可以使用给定的SSLEngineConfigurator创建HTTP服务器,但是如何使用我的tls连接的SSLSocket?还是有另一个网络服务器,这个套接字更容易使用?(我需要http服务器来获取休息服务)
任何想法? 提前谢谢!
了Serverside:
public class SSLServerThread extends Thread implements HandshakeCompletedListener {
private int portNumber;
private SSLServerSocket server;
private SSLSocket client;
public SSLServerThread(int portNumber) {
this.portNumber = portNumber;
}
public void run() {
try {
server = getServer(); // returns the SSLServerSocket
while(true) {
client = (SSLSocket) server.accept();
client.addHandshakeCompletedListener(this);
client.startHandshake();
}
} catch(Exception e) {
e.printStackTrace();
}
}
private SSLServerSocket getServer() {
[..]
}
public void handshakeCompleted(HandshakeCompletedEvent arg0) {
}
}
Clientside:
public class SSLClientThread extends Thread implements HandshakeCompletedListener {
protected int portNumber;
protected SSLSocket client;
public SSLClientThread(int portNumber) {
this.portNumber = portNumber;
}
public void run() {
try {
client = getSocket();
client.addHandshakeCompletedListener(this);
client.startHandshake();
} catch (Exception e) {
e.printStackTrace();
}
}
private SSLSocket getSocket() {
...
}
public void handshakeCompleted(HandshakeCompletedEvent event) {
//start http webserver over this tls secured connection
}
}