how to implement vertx webclient mtls?

30 views Asked by At

server:

    HttpServerOptions options = new HttpServerOptions()
              .setSsl(true)
              .setClientAuth(ClientAuth.REQUIRED)
              .setPemKeyCertOptions(new PemKeyCertOptions().addCertPath(path+"/cert.pem").setKeyPath(path+"/key.pem"))
              ;
            HttpServer server = vertx.createHttpServer(options);

client:

        WebClientOptions options = new WebClientOptions()
                  .setSsl(true)               
                  .setPemKeyCertOptions(new PemKeyCertOptions().addCertPath(path+"/cert.pem").setKeyPath(path+"/key.pem"))                    
                  .setTrustAll(true);
                WebClient client = WebClient.create(vertx, options);

when invoking the client the server shows the error:

javax.net.ssl.SSLHandshakeException: Empty client certificate chain

which, i assume, indicates that the client is not sending the certificate to the server. Question: how do you implement mtls with vertx WebClient ?

1

There are 1 answers

0
ron On

adding:

.setTrustOptions(new PemTrustOptions().addCertPath(path+"/cert.pem"))

to client and server options seems to solve the issue.

any comments, explanations why are welcome.