Is there a way to get the SSL certificate of the authenticated server using Apache HttpClient after the request - just the counterpart to request.getAttribute("javax.servlet.request.X509Certificate") on the server side?
相关问题
- Angular RxJS mergeMap types
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
For HttpClient 4.5 the solution needs to be changed like this:
Ok this is a bit meta in some respects and I'm hopefully doing this in a fashion that will work with any connection manager. I'm assuming you're running on the latest HttpClient (4.2)
So, what you will have to do is add an HttpResponseInterceptor to the client.
Once that is done, any request made through this client will check to see if the connection is marked as 'secure' and then attempt to get the peer certificates.
In this example, I'm just putting in the entire array of certificates that were associated with the peer connection.
At this point, to execute you will do something similar to the following:
Hopefully that will get what you need - if anyone has suggestions beyond this they'd be appreciated.
EDIT This can also be done as a HttpRequestInterceptor and have the same effect as the connection is already established.