java11 微信退款 No appropriate protocol
1.出现问题场景
本地java8编译打包
测试环境java8
线上环境java11
本地编译代码测试环境微信退款正常。
本地编译代代码线上环境微信退款报错,No appropriate protocol。
javax.net.ssl.SSLException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty
at java.base/sun.security.ssl.Alert.createSSLException(Alert.java:133)
at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:320)
at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:263)
at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:258)
at java.base/sun.security.ssl.SSLSocketImpl.handleException(SSLSocketImpl.java:1313)
2. 解决办法
把微信提供的方法中TLSv1改成null
// SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslcontext, new String[]{"TLSv1"}, null, SSLConnectionSocketFactory.BROWSER_COMPATIBLE_HOSTNAME_VERIFIER);
SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslcontext, null, null, new DefaultHostnameVerifier());
还没有评论,来说两句吧...