Glide Caused by: javax.net.ssl.SSLPeerUnverifiedException: Hostname not verified:

简介: Glide Caused by: javax.net.ssl.SSLPeerUnverifiedException: Hostname not verified:

原因是由于服务器不被信任引起的

解决办法:


在 Application 的 onCreate 方法中调用下面方法即可


private fun handleSSLHandshake() {
        try {
            val trustAllCerts: Array<TrustManager> = arrayOf(object : X509TrustManager {
                override fun checkClientTrusted(
                    chain: Array<out X509Certificate>?, authType: String?
                ) = Unit
                override fun checkServerTrusted(
                    chain: Array<out X509Certificate>?, authType: String?
                ) = Unit
                override fun getAcceptedIssuers(): Array<X509Certificate> = arrayOf()
            })
            val sc: SSLContext = SSLContext.getInstance("TLS")
            // trustAllCerts信任所有的证书
            sc.init(null, trustAllCerts, SecureRandom())
            HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory())
            HttpsURLConnection.setDefaultHostnameVerifier(object : HostnameVerifier {
                override fun verify(hostname: String?, session: SSLSession?): Boolean {
                    return true
                }
            })
        } catch (ignored: Exception) {
        }
    }
相关文章
|
网络安全
Caused by: org.springframework.web.client.ResourceAccessException: I/O error on POST request for "http://xxxx.svc.cluster.local:8080/xxxx": Connection reset; nested exception is java.net.SocketException: Connection reset 什么原因导致得
Caused by: org.springframework.web.client.ResourceAccessException: I/O error on POST request for "xxxx.svc.cluster.local:8080/xxxx ": Connection reset; nested exception is java.net.SocketException: Connection reset 什么原因导致得
1947 0
|
6月前
|
开发工具
933.【开发工具】解决idea:Caused by: java.net.BindException: Add
933.【开发工具】解决idea:Caused by: java.net.BindException: Add
72 2
|
6月前
|
NoSQL Linux 网络安全
解决Caused by: java.net.SocketTimeoutException: connect timed out Exception in thread “main“ redis.cli
解决Caused by: java.net.SocketTimeoutException: connect timed out Exception in thread “main“ redis.cli
139 0
|
6月前
|
分布式计算 Linux Spark
【已解决】Caused by: java.net.SocketException: Connection reset by peer: socket write error
【已解决】Caused by: java.net.SocketException: Connection reset by peer: socket write error
189 0
|
TensorFlow 算法框架/工具
ValueError: Negative dimension size caused by subtracting 5 from 1 for ‘{{node le_net5/conv2d/Conv2D
ValueError: Negative dimension size caused by subtracting 5 from 1 for ‘{{node le_net5/conv2d/Conv2D
174 0
|
安全 数据安全/隐私保护
Glide显示不出图片,监听报javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException:
Glide框架是当前比较流行的图片加载框架,使用起来也很简单,肯定有人在使用的时候加载不出图片的,情况有多种,下面讲一下加载不出来捕获到的Exception:javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: 。出现这种情况基本上都是加载https出现的
904 0
Glide显示不出图片,监听报javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException:
|
Java
Caused by: java.lang.IncompatibleClassChangeError: class net.sf.cglib.core.DebuggingClassWriter has
Caused by: java.lang.IncompatibleClassChangeError: class net.sf.cglib.core.DebuggingClassWriter has
289 0
Caused by: java.lang.IncompatibleClassChangeError: class net.sf.cglib.core.DebuggingClassWriter has
|
Apache
javax.net.ssl.SSLException:hostname in certificate didn&#39;t match
终于建了一个自己个人小站:https://huangtianyu.gitee.io,以后优先更新小站博客,欢迎进站,O(∩_∩)O~~ 现在网站用https的服务器越来越多了,在编写程序的时候往往会遇到证书验证错误。
2554 0
|
SQL 分布式计算 Java
Caused by: java.net.ConnectException: Call From master/192.168.199.130 to master:9000 failed on connection exception: java.net.ConnectException: Conne
1:安装好hive,准备启动的时候出现下面的错误(由于hive是基于Hadoop的,所以必须先将你的集群启动起来,我就是没有启动集群,直接启动hive导致的错误): 1 [root@master bin]# .
4091 0
|
分布式计算 Hadoop Linux
一脸懵逼加从入门到绝望学习hadoop之Caused by: java.net.UnknownHostException: master报错
windows下开发hadoop应用程序,hadoop部署在linux环境中, 在运行调试时可能会出现无法找到主机,类似异常信息如下: java.net.UnknownHostException: unknown host: master 解决办法如下: 在C:\WINDOWS\system32\drivers\etc\hosts文件中添加如下信息: 192.
3479 0