Forum Stats

  • 3,758,942 Users
  • 2,251,479 Discussions
  • 7,870,440 Comments

Discussions

How to override ciphers/protocols programatically on JAX-RS client

3352768
3352768 Member Posts: 1
edited Jul 10, 2018 10:07AM in Java User Groups Discussions

I'm facing issue while trying to override ciphers/protocols on JAX-RS client. Jersey framework is used here.

Following is the way client is built.

<span class="typ" style="font-family: inherit; font-style: inherit; font-weight: inherit; color: #2b91af;">Client</span><span class="pln" style="font-family: inherit; font-style: inherit; font-weight: inherit; color: #303336;"> client </span><span class="pun" style="font-family: inherit; font-style: inherit; font-weight: inherit; color: #303336;">=</span><span class="pln" style="font-family: inherit; font-style: inherit; font-weight: inherit; color: #303336;"> </span><span class="typ" style="font-family: inherit; font-style: inherit; font-weight: inherit; color: #2b91af;">ClientBuilder</span><span class="pun" style="font-family: inherit; font-style: inherit; font-weight: inherit; color: #303336;">.</span><span class="pln" style="font-family: inherit; font-style: inherit; font-weight: inherit; color: #303336;">newBuilder</span><span class="pun" style="font-family: inherit; font-style: inherit; font-weight: inherit; color: #303336;">().</span><span class="pln" style="font-family: inherit; font-style: inherit; font-weight: inherit; color: #303336;">sslContext</span><span class="pun" style="font-family: inherit; font-style: inherit; font-weight: inherit; color: #303336;">(</span><span class="pln" style="font-family: inherit; font-style: inherit; font-weight: inherit; color: #303336;">sslContext</span><span class="pun" style="font-family: inherit; font-style: inherit; font-weight: inherit; color: #303336;">).</span><span class="pln" style="font-family: inherit; font-style: inherit; font-weight: inherit; color: #303336;">hostnameVerifier</span><span class="pun" style="font-family: inherit; font-style: inherit; font-weight: inherit; color: #303336;">(</span><span class="pln" style="font-family: inherit; font-style: inherit; font-weight: inherit; color: #303336;">hostnameVerifier</span><span class="pun" style="font-family: inherit; font-style: inherit; font-weight: inherit; color: #303336;">).</span><span class="pln" style="font-family: inherit; font-style: inherit; font-weight: inherit; color: #303336;">build</span><span class="pun" style="font-family: inherit; font-style: inherit; font-weight: inherit; color: #303336;">();</span>

I have tried following approaches, but couldn't succeed.

  1. Created Custom SSLSocketFactory, and override ciphers and protocols on createSocket() method of SSL SocketFactory class. Then, HttpsURLConnection.setDefaultSSLSocketFactory(sf). But, its not reflected with this approach.
  2. Tried overriding the sslcontext with help of SslContextFactory & SSLParameters, which also could help.

Could someone help in finding a way to override ciphers/protocols programatically on sslContext of JAX-RS client?

Answers