英文:
mTLS termination in Java based Vertx Framework
问题
我有一个基于Java的Vertx
框架的项目,其中涉及到一些内部API调用。
因此,流程是我在端口XXXX
上公开了一个API(已配置了TLS - HTTPS
),在这个API调用内部,我正在调用另一个位于HTTP
的负载均衡器。
所以,在调用Http负载均衡器之前,我需要终止mTLS。
以下是VertX POST
调用的示例片段:
private void handleDownstreamRequest(RoutingContext routingContext, String downstreamUrl) {
VertxUtil.assertOnVertxEventLoop();
client.postAbs(downstreamUrl) // POST请求
.sendJson(
routingContext.getBody(),
ar -> {
asyncHttpResponseHandler(ar, routingContext);
});
}
我想知道如何在Vertx框架中终止TLS。Vertx是否提供了任何内置库来终止mTLS,或者任何示例代码片段也将有所帮助。
英文:
I have a project based on Java based Vertx
Framework, where I have few internal API calls.
So the flow is I have an API exposed at port XXXX
(which has TLS configured - HTTPS
), and inside this API call, I am calling another load balancer which is in HTTP
. So, I need to terminate the mTLS before calling the Http load balancer.
Below is the sample snippet for VertX POST
call:
private void handleDownstreamRequest(RoutingContext routingContext, String downstreamUrl) {
VertxUtil.assertOnVertxEventLoop();
client.postAbs(downstreamUrl) // POST request
.sendJson(
routingContext.getBody(),
ar -> {
asyncHttpResponseHandler(ar, routingContext);
});
}
I wanted to know how to terminate the TLS in Vertx Framework. Is there any inbuilt library exposed by Vertx to terminate mTLS or any sample code snippet will also help.
答案1
得分: 1
配置HTTP服务器以使用证书颁发机构,以便验证客户端的身份:
HttpServerOptions options = new HttpServerOptions()
.setSsl(true)
.setClientAuth(ClientAuth.REQUIRED)
.setTrustStoreOptions(
new JksOptions()
.setPath("/path/to/your/truststore.jks")
.setPassword("password-of-your-truststore")
);
HttpServer server = vertx.createHttpServer(options);
上面的示例假设您有一个Java信任存储库,但Vert.x也支持PFX/PEM格式。
英文:
Configure the HTTP server for
You can configure the HTTP server to use a certificate authority in order to verify the identity of the clients:
HttpServerOptions options = new HttpServerOptions()
.setSsl(true)
.setClientAuth(ClientAuth.REQUIRED)
.setTrustStoreOptions(
new JksOptions()
.setPath("/path/to/your/truststore.jks")
.setPassword("password-of-your-truststore")
);
HttpServer server = vertx.createHttpServer(options);
The example above assumes you have a Java trust store but Vert.x support PFX/PEM formats too.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论