在我们的应用程序中,我们当前正在测量SSLSession.getCreationTime()
之间的时间。 (A点)和我们从vertx框架获取请求的时间(B点)作为框架的预请求处理时间。
有时,两点之间的时间大于 10 秒(甚至 20-30 秒)。
至于javax.net.ssl.SSLSession
我想了解 getCreationTime 返回的时间戳代表什么?来自 SSLEngine's docs ,上面写着SSLSession
握手完成后可用。然而,它没有说何时SSLSession
表示已创建。
是否代表
- Client Hello 中的时间戳?
- Server Hello 中的时间戳?
- 握手完成的时间戳?
- 或者其他时间。
不确定在哪里进一步查找以获取更多信息。任何帮助表示赞赏。谢谢。
最佳答案
注意:这个答案纯粹针对服务器端,在客户端,这会有所不同。
查看 SSLEngine 和 ServerHandshaker 的源代码后,看起来 SSLSession
是在服务器收到 Client Hello 时创建的。
来自SSLSessionImpl ,
private final long creationTime = System.currentTimeMillis();
创建时间是在创建SSLSessionImpl
时设置的。
当 session 不是恢复 session 时,会在客户端问候期间创建 SSLSessionImpl
。
来自ServerHandshaker :
private void clientHello(ClientHello mesg) throws IOException {
...
//
// If client hasn't specified a session we can resume, start a
// new one and choose its cipher suite and compression options.
// Unless new session creation is disabled for this connection!
//
if (session == null) {
...
session = new SSLSessionImpl(protocolVersion, CipherSuite.C_NULL,
getLocalSupportedSignAlgs(),
sslContext.getSecureRandom(),
getHostAddressSE(), getPortSE());
...
}
}
SSL 握手完成后,SSLEngine
从握手器(本例中为 ServerHandshaker
)获取 SSLSession
。
来自SSLEngineImpl :
} else if (handshaker.isDone()) {
...
sess = handshaker.getSession();
...
}
TL;DR
当服务器开始处理客户端问候时,在服务器端创建一个SSLSession
。并且创建时间设置为对象创建的时间。
附注
感谢您在没有解释原因的情况下否决了该问题。真正鼓励用户在 SO 中提问。
关于java - javax.net.ssl.SSLSession 创建时间是多少?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60532780/