I'm working for an Android Kotlin project with self-signed SSL cert.
I use Okhttp for connection with server but my app crashes when try to access the server IP and error is saying I need to self sign certificate to access.
I already did many tests by searching internet resources but non of them works for my code. Check my following code and suggest me for better fix.
Please note the URL I put here just for Sample.
val client = OkHttpClient()
var url = "https://00.00.00.000"
val requestBody = FormBody.Builder()
.add("phone", "+9500000000")
.add("token", "03AGdBq26rMv")
.build()
val request = Request.Builder().url(url)
.header("User-Agent", "OkHttp Headers.java")
.addHeader("Content-Type", "application/json")
.addHeader("Accept", "application/json")
.post(requestBody)
.build()
val response = client.newCall(request).execute()
return response.body?.string().toString()
println("Response" + response.body?.string().toString())