2

I have a running code that i am already using to connect to a server using SSL. The API i am using is commons-httpclient-3.1.jar and i cant not upgrade the jar. The servers have upgraded to only use TSL 1.2. Now my existing code is not working. My current code is

HttpClient httpClient = new HttpClient();
        PostMethod post = new PostMethod("https://XYZserver");
        post.getParams().setParameter("http.protocol.version", HttpVersion.HTTP_1_1);
        File f = new File("C://sampleXml.xml");
        RequestEntity entity = new FileRequestEntity(f, "Application/xml");
        post.setRequestEntity(entity);  
        int statusCode = httpClient.executeMethod(post);

If i modify my code as per link How to force Commons HTTPClient 3.1 to use TLS 1.2 only for HTTPS? then my code is working fine.

I have few questions (As i was unable to find their answers?)

  • Why do we require a separate class CustomHttpsSocketFactory. Is it possible to modify existing code to use TLS
    • Is there any other way to do?
Community
  • 1
  • 1
Nimble Fungus
  • 513
  • 3
  • 22

0 Answers0