【发布时间】:2021-06-11 23:12:22
【问题描述】:
在 vert.x Web 应用程序中,是否有人偶然知道如何添加 TLS 1.3 并禁用默认使用的所有先前版本的 TLS(TLS 1.1、TLS 1.2? 非常感谢您的帮助。
【问题讨论】:
标签: tls1.2 vert.x tls1.3 tls1.1
在 vert.x Web 应用程序中,是否有人偶然知道如何添加 TLS 1.3 并禁用默认使用的所有先前版本的 TLS(TLS 1.1、TLS 1.2? 非常感谢您的帮助。
【问题讨论】:
标签: tls1.2 vert.x tls1.3 tls1.1
这取决于您是否要配置用于接收或发送 HTTP 请求的 TLS 版本。
HttpServer 配置 TLS 版本
您正在寻找的是HttpServerOptions 类。您可以提供该类的实例作为vertx.createHttpServer() 的参数。HttpServerOptions 类有两种方法:
serverOptions.addEnabledSecureTransportProtocol()serverOptions.removeEnabledSecureTransportProtocol()
您可以使用它来配置服务器使用的 TLS 版本。
这是一个完整的例子:
final var vertx = Vertx.vertx()
final var serverOptions = new HttpServerOptions();
serverOptions.removeEnabledSecureTransportProtocol("TLSv1");
serverOptions.removeEnabledSecureTransportProtocol("TLSv1.1");
serverOptions.removeEnabledSecureTransportProtocol("TLSv1.2");
serverOptions.addEnabledSecureTransportProtocol("TLSv1.3");
final var server = vertx.createHttpServer(serverOptions);
请查看常量TCPSSLOptions.DEFAULT_ENABLED_SECURE_TRANSPORT_PROTOCOLS,它列出了 Vert.x HTTP 服务器使用的默认 TLS 版本。
还请注意,这个常量的文档说:
由于 POODLE 漏洞http://en.wikipedia.org/wiki/POODLE,SSLv3 未启用
WebClient 配置 TLS 版本
您正在寻找的是WebClientOptions 类。您可以提供该类的实例作为 WebClient.create() 的参数。WebClientOptions 类有两种方法:
clientOptions.addEnabledSecureTransportProtocol()clientOptions.removeEnabledSecureTransportProtocol()
您可以使用它来配置服务器使用的 TLS 版本。
这是一个完整的例子:
final var vertx = Vertx.vertx();
final var clientOptions = new WebClientOptions();
clientOptions.removeEnabledSecureTransportProtocol("TLSv1");
clientOptions.removeEnabledSecureTransportProtocol("TLSv1.1");
clientOptions.removeEnabledSecureTransportProtocol("TLSv1.2");
clientOptions.addEnabledSecureTransportProtocol("TLSv1.3");
final var client = WebClient.create(vertx, clientOptions);
Vert.x WebClient 使用的默认版本使用与服务器中相同的常量指定。
【讨论】: