如何解决在 vert.x web app 中,如何在 web 应用程序中启用 TLS 1.3 的使用
在 vert.x Web 应用程序中,是否有人偶然知道如何添加 TLS 1.3 并禁用默认使用的所有先前版本的 TLS(TLS 1.1、TLS 1.2? 非常感谢您的帮助。
解决方法
这取决于您是否要配置用于接收或发送 HTTP 请求的 TLS 版本。
为 Vert.x 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 服务器使用的 dafault TLS 版本。
另请注意,该常量的文档说明:
由于 POODLE 漏洞 http://en.wikipedia.org/wiki/POODLE
未启用 SSLv3为 Vert.x 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
使用的 dafault 版本使用与服务器中相同的常量指定。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。