英文:
Custom SSLContext per HTTPS request with Apache HTTPAsyncClient
问题
我使用了Apache HTTP Async Client库构建了一个客户端,我有一个HTTP/HTTPS请求的池。问题是我需要使用证书和客户端私钥执行HTTPS请求。我能够做到这一点,但只有一个SSLContext,所以一旦我在那里加载了证书+私钥,所有发送到端点的HTTPS请求都将使用那些证书和密钥,我需要在执行HTTP请求之前执行验证,如果某个条件成立,则将证书加载到请求中,然后我需要能够根据每个HTTPS请求加载证书+私钥。
SSLContext context = SSLContext.getInstance("SSL");
HttpAsyncClient client =
HttpAsyncClients.custom()
.setConnectionManager(manager)
.setSSLContext(context)
.build();
提前感谢。
英文:
I have built a client using Apache HTTP Async Client library, I have a pool of http/https requests. The problem is that I need to execute https requests using a Certificate and Client private key. I was able to do that but there is only one SSLContext, so, once I load a Certificate+Private key there, all HTTPS requests to the endpoint are going to use those certificates+key, I need to execute a validation before doing the http request and load the certificate to the request if certain condition is valid, then, I need to be able to load the Certificate+Private key per https request.
SSLContext context = SSLContext.getInstance("SSL");
HttpAsyncClient client =
HttpAsyncClients.custom()
.setConnectionManager(manager)
.setSSLContext(context)
.build();
Thanks in advance.
答案1
得分: 1
有一个类似的未记录的上下文属性 http.ioSession-factory-registry
,可以用于在每个请求的基础上覆盖默认的 SchemeIOSessionStrategy
。使用时要极其谨慎。
英文:
There is a similar undocumented context attribute http.ioSession-factory-registry
that can be used to override the default SchemeIOSessionStrategy
on a per request basis.
Use with extreme caution.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论