首页 > 编程知识 正文

ssl和tls设置异常,mysql是什么意思

时间:2023-05-05 05:14:12 阅读:134258 作者:4795

1. SSL代码importorg.spring framework.http.client.simpleclienthttprequestfactory; import javax.net.ssl.*; import java.io.IOException; import Java.net.httpurl connection; import Java.security.secure random; import Java.security.cert.x509 certificate;/* * @取消description SSL认证* @ authorjzhao * @ date 2021-4-1517336003 * */publicclassslextendssimpleclienthttprequestfactory { @ overrideprotectedvoidprepareconnection, stringhttpmethod (throwsioexception (if ) preparehttpsconnection ) ) } privatevoidpreparehttpsconnection (httpsurlconnectionconnection ) connection.sethostnameverifier ) newskiphostnameverifier }catch(exceptionex )//ignore ) } privatesslsocketfactorycreatesslsocketfactory ) ) throwsexception ) sslcontext context return context.getSocketFactory (; } privateclassskiphostnameverifierimplementshostnameverifier { @ overridepublicbooleanverify (strings、 SSL session SSL session } privatestaticclassskipx 509 trustmanagerimplementsx 509 trust manager { @ overridepublicx 509 certificate [ ] @ overridepublicvoidcheckclienttrusted (x509 certificate [ ] chain,string authtype ) { } @ overridepublicvoidcheckservertrtrustted stringauthtype ) }2. resttemment importorg.spring framework.context.annotation.bean; importorg.spring framework.context.annotation.configuration; importorg.spring framework.http.client.clienthttprequestfactory; importorg.spring framework.web.client.rest template;/* * @ descriptionresttemplateconfig配置* @ authorjzhao * @ date 2021-4-1516336051 * */@ configuration @ sl F4 jpublicclassresttemplateconfig { @ beanpublicresttemplateresttemplate (clienthttprequestfactoryfactory ) @ beanpublicclienthttprequestfactorysimpleclienthttprequestfactory () { SSL factory=new SSL ); factory.setreadtimeout(5000; factory.setconnecttimeout (15000; //单位为ms return factory; }} 3. HttpClientTempUtil工具类代码import com.Alibaba.fast JSON.JSON object; importorg.spring framework.beans.factory.annotation.auto wired; importorg.spring framework.stereotype.com ponent; importorg.spring framework.web.client.rest template; /** * @Description工具类* @ authorjzhao * @ date 2021-4-1516336045 * */@ componentpublicclasshttpclienttemputil { @ aute @ aute JSONObject params ) jsonobjectjson=rest template.postforentity ) URL,params,JSON return json.toJSONString (; }

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。