websphere解决企业公众号的https问题

调用企业公众号https协议出错:
Caused by: javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure
 at com.ibm.jsse2.n.a(n.java:36)
 at com.ibm.jsse2.n.a(n.java:27)
 at com.ibm.jsse2.sc.b(sc.java:456)
 at com.ibm.jsse2.sc.a(sc.java:381)
 at com.ibm.jsse2.sc.g(sc.java:437)
 at com.ibm.jsse2.sc.a(sc.java:211)
 at com.ibm.jsse2.j.write(j.java:10)
 at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:77)
 at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:135)
 at org.apache.commons.httpclient.HttpConnection.flushRequestOutputStream(HttpConnection.java:828)
 at org.apache.commons.httpclient.HttpMethodBase.writeRequest(HttpMethodBase.java:2116)
 at org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:1096)
 at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:398)
 at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171)
 at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
 at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:323)
 at com.focoon.espublic.common.util.URLUtils.originalGetData(URLUtils.java:236)
 at com.focoon.espublic.platform.corpwx.trade.CorpOaWxCreateAccessToken.createAccessToken(CorpOaWxCreateAccessToken.java:43)
 at com.focoon.espublic.platform.corpwx.batch.impl.CorpOaCreateAccessTokenBatchImpl.executeBatch(CorpOaCreateAccessTokenBatchImpl.java:26)

解决方案:

企业微信号使用的证书类型为TLS,在对应修改无证书加密协议,主要修改类MySecureProtocolSocketFactory.createSSLContext这个方法。有原先的
sslcontext = SSLContext.getInstance("SSL");
sslcontext = SSLContext.getInstance("TLS");

相关推荐