Java load certificate, Access 12306 HTTPS link

Source: Internet
Author: User

Download the 12306 certificate, visit the 12306 website, download the 12306 certificate

650) this.width=650; "src=" Http://www.weare.net.cn/EasyWeb/upload/image/20170106/1483689383822079610.jpg "title=" 1483689383822079610.jpg "alt=" 1111.jpg "style=" Border:0px;vertical-align:middle;height:auto; "/>

Export certificate

650) this.width=650; "src=" Http://www.weare.net.cn/EasyWeb/upload/image/20170106/1483689408281051262.jpg "title=" 1483689408281051262.jpg "alt=" 2222.jpg "style=" Border:0px;vertical-align:middle;height:auto; "/>

650) this.width=650; "src=" Http://www.weare.net.cn/EasyWeb/upload/image/20170106/1483689417663079312.jpg "title=" 1483689417663079312.jpg "alt=" 3333.jpg "style=" Border:0px;vertical-align:middle;height:auto; "/>

Import certificate when export is complete

650) this.width=650; "src=" Http://www.weare.net.cn/EasyWeb/upload/image/20170106/1483689423450086371.jpg "title=" 1483689423450086371.jpg "alt=" 4444.jpg "style=" Border:0px;vertical-align:middle;height:auto; "/>

See if importing

650) this.width=650; "src=" Http://www.weare.net.cn/EasyWeb/upload/image/20170106/1483689431768003797.jpg "title=" 1483689431768003797.jpg "alt=" 5555.jpg "style=" Border:0px;vertical-align:middle;height:auto; "/>

Loading Certificates in Java

Public static void main ( String[] args ) {printwriter out = null;     bufferedreader in = null;    string result  =  "";     //set certificate     system.setproperty (" Javax.net.ssl.trustStore "," D:\\program files\\java\\jdk1.7.0_79\\bin\\12306d.keystore ");       system.setproperty ("Javax.net.ssl.trustStorePassword",  "12306java");       try {        url realurl =  new url ("Https://kyfw.12306.cn/otn/login/loginAysnSuggest");         //  connection between open and URL         urlconnection conn =  realurl.openconnection ();        //  set common request Properties          conn.setrequestpRoperty ("Accept",  "*/*");         conn.setrequestproperty (" Connection ", " keep-alive ");         conn.setrequestproperty (" User-agent ",                " mozilla/4.0  (compatible; msie 6.0; windows nt 5.1; SV1);        //  send a POST request must have the following two lines set          conn.setdooutput (True);         conn.setdoinput (True) ;        //  get the output stream corresponding to the URLConnection object          out = new printwriter (Conn.getoutputstream ());         //  Send request parameter         out.print ("Loginuserdto.user_ name=aaa&userdto.password=123456&randcode=182,51, 19,130 ");         // flush output Stream Buffer          out.flush ();        //  Define the BufferedReader input stream to read the URL response         in = new  BufferedReader (                 new inputstreamreader (Conn.getinputstream ()));         string line;        while  ((Line = in.readLine ())  != null)  {            result  += line;        }         SYSTEM.OUT.PRINTLN (Result);    } catch  (exception e)  {         system.out.println ("Send &nbsP post  Request Unexpected exception! "+e");         e.printstacktrace ();    }     //using the finally block to close the output stream, input stream     finally{         try{            if (out!=null) {                 out.close ();             }             if (in!=null) {                 in.close ();             }         }        catch ( IOEXCEPTION EX) {             Ex.printstacktrace ();         }    }} 


This article by micro-son blog original, blog address: www.weare.net.cn or click Micro-Blog

Java load certificate, Access 12306 HTTPS link

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.