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) {
        }
    }
相关文章
|
13天前
|
存储 网络安全
Curl error (60): SSL peer certificate or SSH remote key was not OK for https://update.cs2c.com.cn/NS/V10/V10SP2/os/adv/lic/base/x86_64/repodata/repomd.xml [SSL: no alternative certificate subject name matches target host name 'update.cs2c.com.cn']
【10月更文挑战第30天】在尝试从麒麟软件仓库(ks10-adv-os)下载元数据时,遇到 SSL 证书验证问题。错误提示为:`Curl error (60): SSL peer certificate or SSH remote key was not OK`。可能原因包括证书不被信任、证书与域名不匹配或网络问题。解决方法包括检查网络连接、导入 SSL 证书、禁用 SSL 证书验证(不推荐)、联系仓库管理员、检查系统时间和尝试其他镜像。
41 1
|
网络安全
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 什么原因导致得
2098 0
|
6月前
|
开发工具
933.【开发工具】解决idea:Caused by: java.net.BindException: Add
933.【开发工具】解决idea:Caused by: java.net.BindException: Add
78 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
146 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
210 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
177 0
|
安全 数据安全/隐私保护
Glide显示不出图片,监听报javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException:
Glide框架是当前比较流行的图片加载框架,使用起来也很简单,肯定有人在使用的时候加载不出图片的,情况有多种,下面讲一下加载不出来捕获到的Exception:javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: 。出现这种情况基本上都是加载https出现的
923 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
290 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的服务器越来越多了,在编写程序的时候往往会遇到证书验证错误。
2564 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]# .
4111 0