当我们将信任管理器与 trustCertCollectionFile 一起使用时,Netty 会跳过主机名验证

Netty skips hostname validation when we use trust manager with trustCertCollectionFile

我正在使用 io netty 4.1 版。19.Final

我正在尝试设置一个将使用 TLS 连接到服务器的客户端。

我希望 netty 在收到 TLS 证书时执行主机名验证,但看起来因为我使用的是使用 TLS 信任文件路径的自定义 trustManager netty 完全跳过了主机名验证。

有没有办法让我使用 TLS 信任文件路径指定自定义 trustManager 并让 io netty 执行主机名验证????

SslContextBuilder builder = SslContextBuilder.forClient();
File trustCertCollection = new File(conf.getTlsTrustCertsFilePath());
builder.trustManager(trustCertCollection);

Netty API:- https://netty.io/4.0/api/io/netty/handler/ssl/SslContextBuilder.html#trustManager-java.io.File-

完整代码:- https://github.com/apache/incubator-pulsar/blob/master/pulsar-client/src/main/java/org/apache/pulsar/client/impl/ConnectionPool.java#L97

你能在 netty 问题跟踪器中打开一个错误并分享一些复制器(最好是单元测试)吗?