netty ssl 客户端中是否有任何方法可以知道服务器在完成 SSL 握手过程后是否请求了客户端证书

Is there any method in netty ssl client to know if server requested client certificate after completion of SSL Handshake process

我有一个 Netty HTTPS(SSL ENABLED) 客户端,它与相互认证 enabled 服务器和相互认证 未启用的服务器

以下是我用来为客户端设置 SSL 处理程序的代码。

TrustManagerFactory tmf= ...// Necessary Trust certs
KeyManagerFactory kmf = ...// Necessary Client certs
SslContext sslContext = SslContextBuilder.forClient().keyManager(kmf).trustManager(tmf).build();
SslHandler sslHandler = sslContex.newHandler(ByteBuffAllocator);

我在管道中使用了上面的sslHandler。我知道如果服务器请求,提供 keyManager(kmf) 将向服务器提供客户端证书。一切正常。

我的需要:我需要知道服务器是否在 SSL 握手过程中请求了客户端证书(即是否启用了相互身份验证的服务器)。我需要在完成握手过程后知道这一点。

您可以提供自己的 KeyManager 实现(稍后调用实际的 KeyManager)。如果调用 getPrivateKey(),您就知道服务器已请求客户端证书。