【问题标题】:In vert.x web app, how to enable the usage of TLS 1.3 in a web application在 vert.x Web 应用程序中,如何在 Web 应用程序中启用 TLS 1.3
【发布时间】: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


    【解决方案1】:

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

    为 Vert.x HttpServer 配置 TLS 版本

    您正在寻找的是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 WebClient 配置 TLS 版本

    您正在寻找的是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 使用的默认版本使用与服务器中相同的常量指定。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-09-24
      • 1970-01-01
      • 2015-07-24
      • 1970-01-01
      • 1970-01-01
      • 2014-01-15
      • 1970-01-01
      相关资源
      最近更新 更多