使用https出错javax.net.ssl.SSLHandshakeException: Handshake failed
来源:互联网 发布:温莎公爵知乎 编辑:程序博客网 时间:2024/05/18 17:24
最近项目中要用到https,android这边使用的是httpsurlconnection来进行访问的。其中遇到了一个非常诡异的问题,在此记录下来,以供参考:
注:https 的证书是后台自己生成的,没有申请合法的证书。
出错日志:
11-10 16:50:32.933: W/System.err(16031): javax.net.ssl.SSLHandshakeException: Handshake failed11-10 16:50:32.933: W/System.err(16031): at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:435)11-10 16:50:32.933: W/System.err(16031): at com.android.okhttp.Connection.upgradeToTls(Connection.java:1323)11-10 16:50:32.933: W/System.err(16031): at com.android.okhttp.Connection.connect(Connection.java:1225)11-10 16:50:32.933: W/System.err(16031): at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:395)11-10 16:50:32.933: W/System.err(16031): at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:298)11-10 16:50:32.933: W/System.err(16031): at com.android.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:399)11-10 16:50:32.933: W/System.err(16031): at com.android.okhttp.internal.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:110)11-10 16:50:32.933: W/System.err(16031): at com.android.okhttp.internal.http.DelegatingHttpsURLConnection.connect(DelegatingHttpsURLConnection.java:89)11-10 16:50:32.933: W/System.err(16031): at com.android.okhttp.internal.http.HttpsURLConnectionImpl.connect(HttpsURLConnectionImpl.java:25)11-10 16:50:32.933: W/System.err(16031): at com.example.httpstest.MainActivity.initSSLALL(MainActivity.java:174)11-10 16:50:32.933: W/System.err(16031): at com.example.httpstest.MainActivity$1.run(MainActivity.java:80)11-10 16:50:32.933: W/System.err(16031): at java.lang.Thread.run(Thread.java:818)11-10 16:50:32.933: W/System.err(16031): Caused by: javax.net.ssl.SSLProtocolException: SSL handshake aborted: ssl=0x7f84498100: Failure in SSL library, usually a protocol error11-10 16:50:32.933: W/System.err(16031): error:14077102:SSL routines:SSL23_GET_SERVER_HELLO:unsupported protocol (external/openssl/ssl/s23_clnt.c:740 0x7f77c0a110:0x00000000)11-10 16:50:32.933: W/System.err(16031): at com.android.org.conscrypt.NativeCrypto.SSL_do_handshake(Native Method)11-10 16:50:32.933: W/System.err(16031): at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:347)11-10 16:50:32.933: W/System.err(16031): ... 11 more
出错的现象:
首先IOS客户端上班是没有问题的。在Android客户端的程序中,android4.x的跑没有任何的问题,但是android5.x上边跑就会一直报上边的异常,而且后台服务器跑的是两台tomcat,android5.x在一台tomcat上跑没有任何问题,在另一台tomcat上边跑一直出错。理论上IOS上没有问题说明后台应该是没有问题的,但是android 端的5,.x在不同的tomcat上边跑结果不同说明两个tomcat的配置是不一样的,非常纠结这个问题,查了很多的资料也没有解决,最后查了好多原因才发现确实是后台的配置没有配好,原因是其中一台tomcat上边的JAVAHOME路径没有配好。最终问题解决。特此记录。
下边是一个使用https的小demo,需要的可以免费下载使用以下:
点击下载
0 0
- 使用https出错javax.net.ssl.SSLHandshakeException: Handshake failed
- javax.net.ssl.SSLHandshakeException: Handshake failed
- com.android.volley.NoConnectionError: javax.net.ssl.SSLHandshakeException: Handshake failed
- 【LeanCloud之坑】javax.net.ssl.SSLHandshakeException:Handshake failed
- OkHttp报错javax.net.ssl.SSLHandshakeException: Handshake failed
- OkHttp报错javax.net.ssl.SSLHandshakeException: Handshake failed
- OkHttp报错javax.net.ssl.SSLHandshakeException: Handshake failed
- javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake
- javax.net.ssl.SSLHandshakeException
- javax.net.ssl.SSLHandshakeException
- javax.net.ssl.SSLHandshakeException
- SSL/TLS的Handshake过程与javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure异常
- SSL/TLS的Handshake过程与javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure异常
- SSL/TLS的Handshake过程与javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure异常
- 使用Java访问https接口javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure
- 解决ant编译Tomcat7出错 javax.net.ssl.SSLHandshakeException
- javax.net.ssl.SSLHandshakeException:PKIX path building failed解决方法
- javax.net.ssl.SSLProtocolException:SSL handshake aborted
- java中实现代理及委托代理模式
- appium对键盘处理
- 回射客户端服务器UDP(echo client&&server based on UDP)
- 34.Android MVC框架 - Robotlegs4Androird
- sublime text 安装插件
- 使用https出错javax.net.ssl.SSLHandshakeException: Handshake failed
- spring、struct、hibernate三大框架整合
- python datetime详解
- Hibernate基于主键的多对多映射2015-11-11
- 线性表
- 蓝懿iOS 技术内容交流和学习心得 11.11
- PostgreSQL安全指南 - Postgres2015全国用户大会--重磅嘉宾佳作分享(周正中)
- OnLongClickListener接口接入
- c++对象