Retrofit handle the SSLHandshakeException

Updated 14 December 2017


This blog focus on Retrofit handle the SSLHandshakeException.

Using Retrofit as your network library is a very good option for android app development. But many a time we face  the SSLHandshakeException ( Trust anchor for certification path not found.) to be particular.

This error means that the secure url you are making request to is not allowing your Retrofit to connect and fetch data.
If you can manage to change the usage from https to http then this will work perfectly fine and you don’t need to actually change anything.

But, if you can’t then you need to modify your retrofit Request builder object ( OkHttpClient.Builder to be particular) so that your application can fetch the data and the exception mentioned in the title is not a hurdle anymore.

Logical Approach

You need to modify your  OkHttpClient.Builder object in your Retrofit request so that your request can actually create a certificate that can be trusted by your server and your server can allow the access to your request.


Modified OkHttpClient.Builder Object.

using this object in your retrofit request.

That’s All.

Keep coding and Keep Sharing.

. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


  • อุรคินทร์ เต็มรัตน์
    Thank you.
    • anchit (Moderator)
      You are welcome 🙂
  • Qudratilla
    Thanks a lot helped
    • anchit (Moderator)
      Your welcome 🙂
  • Mohana
    Thank you so much
    thanks ….. but now statusCode: 400 !!! what is the solution
  • Bill Crandell
    Holly crap you saved me a $2500 loss thank you 50 tablets I needed to work and this made it happen thank you very much…I’ll ask the man to send a few bucks
    • anchit (Moderator)

      It is good to hear that our blog helped you.
      It means a lot.

  • Bill Crandell
    I dont see a donate option for you…
    • anchit (Moderator)
      Thanks for your appreciation.

      But we don’t accept donations for technical blogs.
      These blogs are one of the efforts from our side to make the mobile development community better.

  • Nicodemus Ojwee
    The only solution that worked after 2 days. Thank you so much.
    • anchit (Moderator)
      Your welcome 🙂
  • Deepak
    Thank you so much. You got an awesome blog. Keep up the good work.
    • anchit (Moderator)

      Your Welcome 

  • Feryal
    This solution is great and works fine but the images inside the API doesn’t work, the images also with URL that starts with https, what could be the problem?
    • anchit (Moderator)


      Thanks for your appreciating words.

      The images are perhaps not working becuase you might be using some different library to load the images.

      If this is the case, then please do consider adding something similar for the image library as well.


      If you are not using any library to load the images from a url, then please do let me know how are you loading the images so that i can suggest something.



  • Cristhian Ruiz
    Muchas gracias, en verdad me ayudo mucho.
    • anchit (Moderator)

      Gracias por tus amables palabras


      Consulte también nuestros otros blogs

  • Ivan
    Ты просто красавчик. Спасибо. Реально помогло. Испытал кучу вариантов, но это единственный, что решил проблему.

    You’re just attaboy. Thanks. It really helped. I’ve tried a bunch of options, but this is the only one that solved the problem.

    • anchit (Moderator)

      Добро пожаловать


      Your Welcome

  • Start a Project

      Message Sent!

      If you have more details or questions, you can reply to the received confirmation email.

      Back to Home