我正在编写一个使用SSLEngine和NIO的应用程序,我编写客户端和服务器端。客户端能够连接到服务器,在他连接之后,我希望他能够执行会话恢复/重新协商,但目前没有运气。
因为使用SSLEngine的代码非常大(SSLEngine的使用非常复杂!)我将编写一个简单的伪代码来演示这种情况:
Server:
global sslcontext initialized once
await new client
client.sslEngine = create new server ssl engine using the global sslcontext
client.handleHandshake and wait for it to be done
handle client.
Client:
global sslcontext initialized once
sslEngine = create new client ssl engine using the global sslcontext
performHandshake and wait for it to be done
disconnect (close gracefully the connection)
sslEngine = create new client ssl engine using the global sslcontext
configure engine to not allow session creation
performHandshake and wait for it to be done**我更愿意发布任何可以提供帮助的代码部分(即使是完整的代码,尽管如我所说,它是巨大的。)
当我执行我的程序时,第一个连接成功,但第二个连接导致异常:
javax.net.ssl.SSLHandshakeException: No existing session to resume我是否遗漏了恢复ssl会话所需的一些要素?
发布于 2012-05-16 07:26:30
仅当您使用SSLContext.createEngine(host, port)创建SSLEngine时,它才会恢复会话。否则,它无法知道它在与谁对话,因此无法知道要加入哪个SSLSession。
发布于 2017-02-21 00:06:52
SSLContext应该是单例的。您可以使用netty 4.0.44.Final SslContextBuilder。通过sessionId恢复会话。
private SslContext sslContext;
...
if (serverSSLContext == null) {
serverSSLContext = SslContextBuilder.forServer(new File("cert.crt"), new File("cert.key")).build();
}
channelPipeLine.addLast(serverSSLContext.newHandler(channelPipeLine.channel().alloc()));https://stackoverflow.com/questions/10605062
复制相似问题