PublicSslcontext Createignoreverifyssl ()throwskeymanagementexception, NoSuchAlgorithmException, keystoreexception {sslcontext sc=NewSslcontextbuilder (). Loadtrustmaterial (NULL,NewTruststrategy () { Public BooleanIsTrusted (x509certificate[] arg0, String arg1)throwscertificateexception {return true; }}). Build (); returnSC; } protectedHttpClient gethttpclient ()throwsException {httpclientbuilder builder=httpclientbuilder.create (); Sslconnectionsocketfactory sslconnsocketfactory=Newsslconnectionsocketfactory (Createignoreverifyssl ()); Builder.setsslsocketfactory (sslconnsocketfactory); Registry<ConnectionSocketFactory> Registry = registrybuilder.<connectionsocketfactory> Create (). Register (" Https, Sslconnsocketfactory). Build (); Httpclientconnectionmanager CCM=NewBasichttpclientconnectionmanager (registry); Builder.setconnectionmanager (CCM); returnBuilder.build (); }
Https Ignore certificate \ Java code implementation using custom certificate