About HTTP requires two jar packages httpclient-4.0.jarhttpcore-4.0.1.jarprivate static final httpclient httpclient = new Defaulthttpclien T (); try {//Get key library KeyStore Truststore = keystore.getinstance ("JKs"); String keystorefile = "Xxxxx.keystore"; String keypwd = "xxxxxxx"; FileInputStream instream = new FileInputStream (new File (Keystorefile)); Key Library Password truststore.load (instream, Keypwd.tochararray ()); Register Key Library Sslsocketfactory socketfactory = new Sslsocketfactory (Truststore); Do not verify the domain name Socketfactory.sethostnameverifier (sslsocketfactory.allow_all_hostname_verifier); Scheme sch = new scheme ("https", socketfactory, 443); Httpclient.getconnectionmanager (). Getschemeregistry (). Register (sch);} catch (Exception e) {e.printstacktrace ();} The following paragraph is the calling code, there are many ways to do so, not limited to httpposthttppost HttpPost = new HttpPost (URL); stringentity entity = new stringentity (params); Entity.setcontentencoding ("UTF-8"); httppost.setentity (entity);// Send Request HttpResponse response = HttpclieNt.execute (HttpPost); String jsonstr = entityutils.tostring (Response.getentity ());
Java implements HTTPS one-way authentication