You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
val certManager =CertManager()
val certData = certManager.createCertData(context)
val httpClient =OkHttpClient
.Builder()
.sslSocketFactory(certData.sslContext.socketFactory, certData.x509TrustManager)
.build()
//todo use OkHttpClient
Пример использования с HttpUrlConnection
val certManager =CertManager()
val certData = certManager.createCertData(context)
HttpsURLConnection.setDefaultSSLSocketFactory(certData.sslContext.socketFactory)
//todo use HttpConnection library
Пример использования с WebView
val certManager =CertManager()
val certData = certManager.createCertData(context)
webView.webViewClient =object:WebViewClient()
{
overridefunonReceivedSslError(view:WebView?, handler:SslErrorHandler, error:SslError)
{
if (SslErrorVerifier.verifySslError(error, certData.trustManagerFactory))
{
handler.proceed()
} else
{
handler.cancel()
}
}
}
webView.loadUrl("https://www.google.com/")