//信任所有证书而睡着的草莓publicstaticokhttpclientgethttps ((okhttpclientokhttpclient=newokhttpclient.builder ) ) ) ) e verifier ({ @ overridepublicbooleanverify (string hostname,SSLSession session ) )。 } ).SSL socket factory (createsslsocketfactory () ) ).build ); returnokhttp客户端; post请求publicstaticstringdoposthttps (string URL,Headers headers,RequestBody body ) { request.builder builder=new requestbody If (头部!=null}{builder.headers(headers ); }builder.post(body; int maxRetryTime=1; int time=0; 字符串结果=null; do { time; try { Response response=getHttps ().new call (builder.build ) ).execute ); if(response.issuccessful ) ) response.body )!=null(result=response.body ).string ); } else { log.error (接口请求)失败^_^ headers:{} ^_^返回值:{},url,'',result ); }catch(ioexceptione ) { e.printStackTrace ); } while (null==resulttimemaxretrytime; return null==result? ' ' :结果; //在此创建jsdhy,上面的. sslSocketFactory () privatesslsocketfactorycreatesslsocketfactory ) ) sslSocketFactory sc.init(null,newtrust manager [ ] { newtrustallcerts (},new SecureRandom ) }; ssfFactory=sc.getSocketFactory (; }catch(exceptione ) { } return ssfFactory; } publicclasstrustallcertsimplementsx 509信任管理器{ @ overridepublicvoidcheckclienttrusted (x509 certificate [ ] chain, string authtype (throwscertificateexception { } @ overridepublicvoidcheckservertrusted (x509 certificate [ ] chain, string authtype (throwscertificateexception { } @ overridepublicx 509 certificate [ ] getacceptedissuers ) { return new x509 certififon