WebService系列之SSL异常handshake failure处理方法

WebService系列之SSL异常handshake failure处理方法

最近在使用axis调用一个https的接口,调用时候一直报异常:

javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure

网上说法有设置TLS:

System.setProperty("https.protocols", "TLSv1.2,TLSv1.1,TLSv1.0,SSLv3");

不过抛出异常,需要注意,如果是jdk8就不需要设置TLSv1.0,jdk6有些版本不能设置TLSv1.1

不同版本jdk对TLS验证是有差别的:oracle官网博客Diagnosing TLS, SSL, and HTTPS列出了差别
在这里插入图片描述
在这里插入图片描述
然而这种设置TLS协议方法并不能处理问题,然后在https://stackoverflow.com/,找到方法:
在这里插入图片描述
意思是需要下载oracle官网的jar:

下载之后,将两个jar放在$JAVA_HOME/jre/lib/ext,找到找到security.provider.9,然后在这句话下面加上:

security.provider.10=org.bouncycastle.jce.provider.BouncyCastleProvider

参考资料:
解决 JAVAX.NET.SSL.SSLEXCEPTION: JAVA.LANG.RUNTIMEEXCEPTION: COULD NOT GENERATE DH KEYPAIR
https://www.cnblogs.com/yinliang/p/9929595.html

smileNicky CSDN认证博客专家 分布式 Java Spring
java程序员,软件工程专业,专注于sql调优,SpringBoot,spring框架学习,个人邮箱nickypm@foxmail.com,公众号nickymp
已标记关键词 清除标记
<div><h4>Issue description</h4> <p><em>write the description here</em></p> <p>There appears to be some sort of requests handshake issue:</p> <p>All matching attempt leads to this:</p> <p>Traceback (most recent call last): File "/usr/local/lib/python3.6/site-packages/IMDbPY-6.6.dev20180501-py3.6.egg/imdb/parser/http/<strong>init</strong>.py", line 183, in retrieve_unicode uopener = self.open(url) File "/usr/local/lib/python3.6/urllib/request.py", line 1763, in open raise OSError('socket error', msg).with_traceback(sys.exc_info()[2]) File "/usr/local/lib/python3.6/urllib/request.py", line 1757, in open return getattr(self, name)(url) File "/usr/local/lib/python3.6/urllib/request.py", line 1936, in open_http return self._open_generic_http(http.client.HTTPConnection, url, data) File "/usr/local/lib/python3.6/urllib/request.py", line 1932, in _open_generic_http response.status, response.reason, response.msg, data) File "/usr/local/lib/python3.6/urllib/request.py", line 1948, in http_error result = method(url, fp, errcode, errmsg, headers) File "/usr/local/lib/python3.6/urllib/request.py", line 2136, in http_error_302 headers, data) File "/usr/local/lib/python3.6/urllib/request.py", line 2167, in redirect_internal return self.open(newurl) File "/usr/local/lib/python3.6/urllib/request.py", line 1763, in open raise OSError('socket error', msg).with_traceback(sys.exc_info()[2]) File "/usr/local/lib/python3.6/urllib/request.py", line 1757, in open return getattr(self, name)(url) File "/usr/local/lib/python3.6/urllib/request.py", line 1967, in open_https return self._open_generic_http(self._https_connection, url, data) File "/usr/local/lib/python3.6/urllib/request.py", line 1916, in _open_generic_http http_conn.request("GET", selector, headers=headers) File "/usr/local/lib/python3.6/http/client.py", line 1239, in request self._send_request(method, url, body, headers, encode_chunked) File "/usr/local/lib/python3.6/http/client.py", line 1285, in _send_request self.endheaders(body, encode_chunked=encode_chunked) File "/usr/local/lib/python3.6/http/client.py", line 1234, in endheaders self._send_output(message_body, encode_chunked=encode_chunked) File "/usr/local/lib/python3.6/http/client.py", line 1026, in _send_output self.send(msg) File "/usr/local/lib/python3.6/http/client.py", line 964, in send self.connect() File "/usr/local/lib/python3.6/http/client.py", line 1400, in connect server_hostname=server_hostname) File "/usr/local/lib/python3.6/ssl.py", line 407, in wrap_socket _context=self, _session=session) File "/usr/local/lib/python3.6/ssl.py", line 814, in <strong>init</strong> self.do_handshake() File "/usr/local/lib/python3.6/ssl.py", line 1068, in do_handshake self._sslobj.do_handshake() File "/usr/local/lib/python3.6/ssl.py", line 689, in do_handshake self._sslobj.do_handshake() OSError: [Errno socket error] [Errno socket error] EOF occurred in violation of protocol (_ssl.c:833)</p> <h4>Version of IMDbPY, Python and OS</h4> <ul><li><strong>Python:</strong> <code>python3 -V</code> or, if you are using Python 2, <code>python -V</code></li><li><strong>IMDbPY:</strong> <code>python3 -c 'import imdb ; print(imdb.VERSION)'</code> or, if you are using Python 2, <code>python -c 'import imdb ; print(imdb.VERSION)'</code></li><li><strong>OS:</strong> <code>python -c 'import platform ; print(platform.uname())'</code></li></ul> <p>python - Python 3.6.5rc1 imdbpy - 6.6dev20180415 OS - uname_result(system='Linux', node='ushapld00167.stg-tfayd.com', release='2.6.32-573.26.1.el6.x86_64', version='#1 SMP Tue May 3 12:39:43 PDT 2016', machine='x86_64', processor='x86_64')</p> <h4>Steps to reproduce the issue</h4> <p><em>if possible, provide a minimal code to reproduce the problem</em></p> <pre><code> #!python # your code here </code></pre> <p>ia = imdb.IMDb() ia.set_proxy(proxy) results = ia.search_movie(title)</p> <h4>What's the expected result?</h4> <p>-A search for movies.</p> <h4>What's the actual result?</h4> <ul><li>SSL handshake issues.</li></ul> <h4>Additional details</h4> <ul><li>I've attempting force reinstalling every module I can think of.</li></ul><p>该提问来源于开源项目:alberanid/imdbpy</p></div>
```一月 05, 2018 6:28:16 下午 org.apache.catalina.core.StandardWrapperValve invoke 严重: Servlet.service() for servlet [Spring MVC Dispatcher Servlet] in context with path [/eLearningSystem] threw exception [Request processing failed; nested exception is org.springframework.web.socket.server.HandshakeFailureException: Uncaught failure for request http://127.0.0.1:8085/eLearningSystem/ws.do?CFAPP_USERNAME=admin; nested exception is java.lang.NoSuchMethodError: org.springframework.web.socket.WebSocketHttpHeaders.getUpgrade()Ljava/lang/String;] with root cause java.lang.NoSuchMethodError: org.springframework.web.socket.WebSocketHttpHeaders.getUpgrade()Ljava/lang/String; at org.springframework.web.socket.server.support.DefaultHandshakeHandler.doHandshake(DefaultHandshakeHandler.java:171) at org.springframework.web.socket.server.support.WebSocketHttpRequestHandler.handleRequest(WebSocketHttpRequestHandler.java:120) at org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter.handle(HttpRequestHandlerAdapter.java:49) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:925) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:936) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:827) at javax.servlet.http.HttpServlet.service(HttpServlet.java:624) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:812) at javax.servlet.http.HttpServlet.service(HttpServlet.java:731) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:73) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at cn.learning.filter.SessionFilter.doFilter(SessionFilter.java:55) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at cn.learning.pager.PagerFilter.doFilter(PagerFilter.java:28) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at cn.learning.filter.EncryptionRequestFilter.doFilter(EncryptionRequestFilter.java:199) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:61) at org.apache.shiro.web.servlet.AdviceFilter.executeChain(AdviceFilter.java:108) at org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:137) at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125) at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:66) at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449) at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365) at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90) at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83) at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:383) at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362) at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:218) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:442) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1082) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:623) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:745) ``` 请各位大神帮帮忙,我下载的demo上传的时候Upgrade的值也是个字符串数组。 但是我集成到项目里就报这个错了,在网上搜了找解决方案,都没出现过这样的情况,不知道该怎么修改。
©️2020 CSDN 皮肤主题: 岁月 设计师:pinMode 返回首页
实付 9.90元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值