0

在 vert.x Web 应用程序中,是否有人偶然知道如何添加 TLS 1.3 并禁用默认使用的所有先前版本的 TLS(TLS 1.1、TLS 1.2?非常感谢您的帮助。

4

1 回答 1

0

这取决于您是否要配置用于接收或发送 HTTP 请求的 TLS 版本。

为 Vert.x 配置 TLS 版本HttpServer

您正在寻找的是HttpServerOptions课程。您可以提供该类的实例作为vertx.createHttpServer().
该类HttpServerOptions有两个方法:

您可以使用它来配置服务器使用的 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

为 Vert.x 配置 TLS 版本WebClient

您正在寻找的是WebClientOptions课程。您可以提供该类的实例作为WebClient.create().
该类WebClientOptions有两个方法:

您可以使用它来配置服务器使用的 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与服务器中相同的常量指定。

于 2021-03-15T09:04:12.913 回答