i am using REST api to connect with server on ssl https the problm is on android kitkat devices. all device with kitkat version or 4.x.x are not making connection with server
javax.net.ssl.SSLException: Connection closed by peer at com.android.org.conscrypt.NativeCrypto.SSL_do_handshake(Native Method)
on all above devices than 4.x.x working fine and making connection
Is there any solution for that. i have also tried OkHttp which is also not working in my cause.
I faced a similar problem before, where my endpoint was using TLS 1.2 for encryption. If your endpoint is using https
you could try change to http
for unencrypted api call. If that is an option.
If you are only releasing your app on devices with Google Play Services
you can use ProviderInstaller
to provide support for TLS 1.2
fun installSecurityProvider() {
try {
ProviderInstaller.installIfNeeded(activity)
} catch (e: GooglePlayServicesRepairableException) {
handlePlayServicesError(e.connectionStatusCode)
} catch (e: GooglePlayServicesNotAvailableException) {
handleCriticalFailure()
}
}
https://developer.android.com/training/articles/security-gms-provider.html
There was an issue opened on the okhttp git page which discussed this problem.
https://github.com/square/okhttp/issues/3098
If relying on play services is not an option then its possible to implement yourself.
https://github.com/square/okhttp/issues/2372#issuecomment-244807676
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With