3

I tried setting the environment variable in my Intellij Idea under run/debug configurations like: -Dhttps.protocols=TLSv1.2, as well as setting it programmatically like:

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

I also tried setting this property to my RESTEasy client directly like:

javax.ws.rs.client client = ClientBuilder.newBuilder().build();
client.property("https.protocols", "TLSv1.2");

but with no success. What else can I do to enforce my client to use TLSv1.2?

Arthur Eirich
  • 3,368
  • 9
  • 31
  • 63
  • Try and set the [`SSLContext`](http://docs.oracle.com/javase/7/docs/api/javax/net/ssl/SSLContext.html#getInstance%28java.lang.String%29), as seen in [step 6 of this post](http://stackoverflow.com/a/28472044/2587435) – Paul Samsotha Mar 07 '15 at 01:23

1 Answers1

0

You could get the SSLContext instance and pass it to the builder as follows (exception handling omitted):

SSLContext sslContext = SSLContext.getInstance("TLSv1.2");
// The SSL context must be explicitly initialized
sslContext.init(null, null, null);
ResteasyClient restClient = new ResteasyClientBuilder().sslContext(instance).build();
Egemen
  • 2,178
  • 5
  • 22
  • 32