Android OKHttp SSLPeerUnverifiedException / SSLHandshakeException

I connected Google, for example: ( https://finance.google.com/finance?q=NASDAQ%3AAAPL ) with the android okhttp client, but it gives an error:

javax.net.ssl.SSLPeerUnverifiedException: Hostname www.google.com not verified: certificate: sha256/7ygD2cyU8sl30bjSfYs6WWBQ1IZVLiPNK04Tfzf5VPk= DN: CN=*.facebook.com,O=Facebook\, Inc.,L=Menlo Park,ST=California,C=US subjectAltNames: [*.facebook.com, *.xx.fbcdn.net, *.fbsbx.com, *.xz.fbcdn.net, *.facebook.net, *.xy.fbcdn.net, *.messenger.com, fb.com, *.fbcdn.net, *.fb.com, *.m.facebook.com, messenger.com, facebook.com] 

2 days later I received

 javax.net.ssl.SSLPeerUnverifiedException: Hostname www.google.com not verified: certificate: sha256/H7hNBz7v4J3Nf2Mj+xzmfoq5xJRS8cXC0gZO+LO06eA= DN: CN=syndication.twitter.com,OU=Twitter Security,O=Twitter\, Inc.,L=San Francisco,ST=California,C=US subjectAltNames: [syndication.twitter.com, cdn.syndication.twitter.com, syndication-o.twitter.com, syndication.twimg.com, cdn.syndication.twimg.com, syndication-o.twimg.com] at okhttp3.internal.connection.RealConnection.connectTls(RealConnection.java:316) 

I tried

 builder.hostnameVerifier(new HostnameVerifier() { @Override public boolean verify(String hostname, SSLSession session) { return true; } }); 

But no luck.

It also throws an exception, as shown below:

javax.net.ssl.SSLHandshakeException: Connection closed by peer at com.android.org.conscrypt.NativeCrypto.SSL_do_handshake(Native Method) at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:324) at okhttp3.internal.connection.RealConnection.connectTls(RealConnection.java:302)

an exception.

Connection, it works before, but in recent days, if it failed, maybe the google server has updated something these days? What should I do?

+5
source share
1 answer

it looks like this is due to my proxy.

+2
source

Source: https://habr.com/ru/post/1275930/


All Articles