Redeem Now
Read More
Read now

Retrofit handle the SSLHandshakeException


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.

. . .

Comments (11)

Add Your Comment

  • อุรคินทร์ เต็มรัตน์
    Thank you.
    • anchit
      You are welcome 🙂
  • Qudratilla
    Thanks a lot helped
    • anchit
      Your welcome 🙂
  • Mohana
    Thank you so much
  • 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

      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
      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
      Your welcome 🙂
  • css.php
    Hire Us!
    Brief us about your requirements and we'll get back to you.
    Woo! Hooy!
    We have just recieved your project brief and our expert will contact you shortly.
    Send Again