本文主要记录如果解决weblogic使用URL.openConnection出现javax.net.ssl.SSLKeyException:
[Security:090504]。。。。。。。的异常,tomcat下一切正常。
在解决问题之前查看了http://blog.youkuaiyun.com/arvinrong/article/details/7715334和http://winters1224.blog.51cto.com/3021203/1313111这两篇文章的建议(感谢两位作者),原因这两位分析的很清晰了,最终采用一种简单的方式(无须修改weblogic代理配置),如下:
- URL url = new URL(null,urlStr,new sun.net.www.protocol.https.Handler());//重点在这里,需要使用带有URLStreamHandler参数的URL构造方法
- HttpsURLConnection httpConnection = (HttpsURLConnection) url.openConnection();//由于我调用的是官方给微信API接口,所以采用HTTPS连接
- int responseCode = httpConnection.getResponseCode();
- if (responseCode == HttpURLConnection.HTTP_OK) {
- InputStream urlStream = httpConnection.getInputStream();
- BufferedReader bufferedReader = new BufferedReader(
- new InputStreamReader(urlStream));
- String lineStr = "";
- while ((lineStr = bufferedReader.readLine()) != null) {
- ......
- }
- .....
- }
本文介绍了解决在WebLogic环境下使用URL.openConnection方法时遇到的SSLKeyException异常问题。通过采用特定的URL构造方法,成功避免了异常发生,并保持了与微信API接口的正常HTTPS连接。
1076

被折叠的 条评论
为什么被折叠?



