标签: vertx4

Vert.x将http重定向到https

我们用Vert.x 4重新编写了我们的Web服务,我们感到非常满意。在将它们投入生产之前,我们要保护它们安全,并尝试启用https。这是主要版本:

public class MainVerticle extends AbstractVerticle {

  @Override
  public void start() throws Exception {
    //Deploy the HTTP server
    vertx.deployVerticle(
      "com.albertomiola.equations.http.HttpServerVerticle",
      new DeploymentOptions().setInstances(3)
    );
  }

  // I use this only in IntelliJ Idea because when I hit "Run" the build starts
  public static void main(String[] args) {
    Launcher.executeCommand("run", MainVerticle.class.getName());
  }

}
Run Code Online (Sandbox Code Playgroud)

这是HTTP服务器Verticle代码中最相关的部分:

public class HttpServerVerticle extends AbstractVerticle {

  @Override
  public void start(Promise<Void> startPromise) throws Exception {
    var options = new HttpServerOptions();
    options.setPort(443)
           .setSSl(true)
           .setPemTrustOptions(...)
           .setPemKeyCertOptions(...);

    var server = vertx.createHttpServer(options);
    var …
Run Code Online (Sandbox Code Playgroud)

java vert.x java-11 vertx4

5
推荐指数
1
解决办法
147
查看次数

标签 统计

java ×1

java-11 ×1

vert.x ×1

vertx4 ×1