Showing posts with label filecert. Show all posts
Showing posts with label filecert. Show all posts

Wednesday, August 23, 2017

Android Adding File Certificate To Retrofit 2.0+

After the previous post about how to adding file certificate to Retrofit 1.7, today i gonna share a new tutorial about how to adding file certificate to Retrofit 2.0.


As you know, one of usage of file certificate is used to access HTTPS from HTTP. If your current host is HTTPS but you still access using HTTP , so by using file certificate it will be redirecting to HTTPS automatically.

Before you adding file certificate to Retrofit 2.0 make you using OKHTTP 3 for your client. So here is the method that you can use for adding file certificate to Retrofit 2.0 :

First import the following package :

Here the method that i use in my project, write the following method (you can modify the method as you wish) :

That's all, hope it helps and works. Thank you.

Tuesday, August 22, 2017

Android Add File Certificate To Retrofit 1.7

In current  project that you develop from the beginning you must be use the latest version of the library, for example library Retrofit.



In several case, you must be face a difficulty in Retrofit 1.7 how to add file certificate to Retrofit 1.7, right?

Because of this, i create this article and share my experience when i add file certificate to my apps using Retrofit 1.7

If you using Retrofit 1.7, make sure another support libraries are added, these libraries that i meant are :

compile 'com.squareup.okhttp:okhttp:2.0.0'
compile 'com.squareup.okio:okio:1.13.0'
compile 'com.squareup.okhttp:okhttp-urlconnection:2.0.0'

After that, write to the following code in your apps to adding file certificate to Retrofit 1.7 :

Above is some code snippet in my project. I don't how the model of your code, but you can modify my code above and implement in your project. If you are using Retrofit 1.7, then my code will works in your project.

That's all about how to adding file Certificate to Retrofit 1.7, hope it helps and works in your project. Thank you.