-
-
Save virendersran01/631731dcb3cb5cde47bea19aa6a0e901 to your computer and use it in GitHub Desktop.
Including support for TLS/SSL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Singleton | |
@Provides | |
fun provideOkhttpClient(authInterceptor: AuthInterceptor, | |
certificateHelper: CertificateHelper | |
) :OkHttpClient{ | |
val trustManagers = certificateHelper.createTrustManagers() | |
val sslContext = SSLContext.getInstance("TLS") | |
sslContext.init(null, trustManagers, null) | |
return OkHttpClient().newBuilder() | |
.readTimeout(2, TimeUnit.MINUTES) | |
.writeTimeout(2, TimeUnit.MINUTES) | |
.connectTimeout(2, TimeUnit.MINUTES) | |
.addInterceptor(authInterceptor) | |
.addInterceptor(loggingInterceptor) | |
.sslSocketFactory(sslContext.socketFactory, | |
trustManagers[0] as X509TrustManager) | |
.build() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment