java - Any Apache HttpClient 4.4 Example for trust self signed certificates -
i changed httpclient
version old version new 4.4
.
and got many deprecated method , class. original codes can trust self signed certificates , want replace new method , class.
could 1 give me guide line how replace or example code?
thank you.
i disable certificate verification (remember, it's insecure), using alin's answer, had modify code way:
sslcontext sslcontext = sslcontexts .custom () .loadtrustmaterial ( null, new truststrategy () { public boolean istrusted ( x509certificate[] chain, string authtype ) throws certificateexception { return true; } }) .build(); sslconnectionsocketfactory sslsf = new sslconnectionsocketfactory ( sslcontext, null, null, new noophostnameverifier () ); httpclient httpclient = httpclients .custom() .setsslsocketfactory ( sslsf ) .build(); ...
as can see, use liberal truststrategy
possible, because trustselfsignedstrategy
giving me "unable find valid certification path requested target". moreover, seems don't need pass new string[] { "tlsv1" }
sslconnectionsocketfactory
, null
should interpreted "all protocols".
this available here, can link maven, through repo reported here.
Comments
Post a Comment