2

I am using FileUtils.copyURLToFile to copy a url into a local file. The URL is using https. It worked perfectly fine until they changed the SSL version.

Is there a way to specify the SSL version with the apache commons.io? eg something like in this question but allowing me to keep using FileUtils.copyURLToFile.

Community
  • 1
  • 1
Thomas
  • 1,967
  • 2
  • 15
  • 22

1 Answers1

3

As a workaround you can use HttpsURLConnection to open connection, set SSL version and then use FileUtils.copyURLToFile:

SSLContext context = SSLContext.getInstance("TLSv1.2");

context.init(null, null, null);

HttpsURLConnection.setDefaultSSLSocketFactory(context.getSocketFactory());

HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();

FileUtils.copyURLToFile(connection.getURL(), file);