I have the following kotlin code:
val urlPath = "https://10.0.2.2:8080"
var data: String
try {
data = URL(urlPath).readText()
} catch (e: Exception) {
Log.e("doInBackground", "Exception caught: ${e.localizedMessage}")
error = when (e) {
is MalformedURLException -> "Invalid URL"
is IOException -> "Network Error"
else -> {
"Network error: ${e.localizedMessage}"
}
}
}
If I use the above code to connect to a http server, the above code works. However when I try to connect to a https server with a self-signed certificate, it fails. Is there a way to allow https connections on localhost (only), even when the certificates are self-signed ?