0

I have a Google App Engine Java 7 server which makes HTTP connections to an API:

    // Setup
    HttpClient client = new DefaultHttpClient();
    HttpPost request = new HttpPost(Url);
    request.setEntity(new StringEntity(Xml));

    // Execute request and extract response
    ResponseHandler<String> response = new BasicResponseHandler();
    String body = client.execute(request, response);

    return body;

However this is failing because the service to which I am connecting has stopped accepting TLS v1.0 and v1.1 connections, and only accepts TLS v1.2. How can I adapt my server or code to this change?

I have already seen other reports that this can be done in Java 8, but can this be done without updating the Java version?

Update

I have added the following just before the 'Setup' above:

    System.setProperty("https.protocols", "TLSv1.2");

    Socket socket = SSLSocketFactory.getDefault().createSocket();
    String[] tlsVersions = {"TLSv1.2"};
   ((SSLSocket)socket).setEnabledProtocols(tlsVersions);

However I am getting the error Received fatal alert: handshake_failure on Google App Engine. Can anyone advise?

user2181948
  • 1,646
  • 3
  • 33
  • 60

1 Answers1

0

If you are using windows then set environment variable -Dhttps.protocols=TLSv1.1,TLSv1.2

spdev
  • 21
  • 3