<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    少年阿賓

    那些青春的歲月

      BlogJava :: 首頁 :: 聯系 :: 聚合  :: 管理
      500 Posts :: 0 Stories :: 135 Comments :: 0 Trackbacks

    Here’s a simple Java HTTPS client to demonstrate the use of HttpsURLConnection class to print a https URL content and certificate detail.

    Access https URL : https://www.google.com/


    package com.mkyong.client;
     
    import java.net.MalformedURLException;
    import java.net.URL;
    import java.security.cert.Certificate;
    import java.io.*;
     
    import javax.net.ssl.HttpsURLConnection;
    import javax.net.ssl.SSLPeerUnverifiedException;
     
    public class HttpsClient{
     
       public static void main(String[] args)
       {
            new HttpsClient().testIt();
       }
     
       private void testIt(){
     
          String https_url = "https://www.google.com/";
          URL url;
          try {
     
    	     url = new URL(https_url);
    	     HttpsURLConnection con = (HttpsURLConnection)url.openConnection();
     
    	     //dumpl all cert info
    	     print_https_cert(con);
     
    	     //dump all the content
    	     print_content(con);
     
          } catch (MalformedURLException e) {
    	     e.printStackTrace();
          } catch (IOException e) {
    	     e.printStackTrace();
          }
     
       }
     
       private void print_https_cert(HttpsURLConnection con){
     
        if(con!=null){
     
          try {
     
    	System.out.println("Response Code : " + con.getResponseCode());
    	System.out.println("Cipher Suite : " + con.getCipherSuite());
    	System.out.println("\n");
     
    	Certificate[] certs = con.getServerCertificates();
    	for(Certificate cert : certs){
    	   System.out.println("Cert Type : " + cert.getType());
    	   System.out.println("Cert Hash Code : " + cert.hashCode());
    	   System.out.println("Cert Public Key Algorithm : " + cert.getPublicKey().getAlgorithm());
    	   System.out.println("Cert Public Key Format : " + cert.getPublicKey().getFormat());
    	   System.out.println("\n");
    	}
     
    	} catch (SSLPeerUnverifiedException e) {
    		e.printStackTrace();
    	} catch (IOException e){
    		e.printStackTrace();
    	}
     
         }
     
       }
     
       private void print_content(HttpsURLConnection con){
    	if(con!=null){
     
    	try {
     
    	   System.out.println("****** Content of the URL ********");			
    	   BufferedReader br = 
    		new BufferedReader(
    			new InputStreamReader(con.getInputStream()));
     
    	   String input;
     
    	   while ((input = br.readLine()) != null){
    	      System.out.println(input);
    	   }
    	   br.close();
     
    	} catch (IOException e) {
    	   e.printStackTrace();
    	}
     
           }
     
       }
     
    }

    Output…

    Response Code : 200
    Cipher Suite : SSL_RSA_WITH_RC4_128_SHA
     
    Cert Type : X.509
    Cert Hash Code : 7810131
    Cert Public Key Algorithm : RSA
    Cert Public Key Format : X.509
     
    Cert Type : X.509
    Cert Hash Code : 6042770
    Cert Public Key Algorithm : RSA
    Cert Public Key Format : X.509
     
    ****** Content of the URL ********
    <!doctype html><html><head><meta http-equiv="content-type" ......
    posted on 2012-08-16 00:17 abin 閱讀(1925) 評論(1)  編輯  收藏 所屬分類: httpClient

    Feedback

    # re: Java HTTPS Client – HttpsURLConnection Example 2014-09-27 21:55 help
    把地址改為https://member.my089.com/,程序報錯,是什么原因呢  回復  更多評論
      

    主站蜘蛛池模板: 特级一级毛片免费看| 亚洲欧洲校园自拍都市| 97在线观免费视频观看| 免费国产污网站在线观看| 豆国产96在线|亚洲| 亚洲国产精品嫩草影院| 久久久久久久久久免免费精品| 野花香高清在线观看视频播放免费 | 亚洲精品在线免费观看视频| 日韩一区二区在线免费观看| 中文字幕无码毛片免费看| 亚洲精品伊人久久久久| 亚洲最大AV网站在线观看| 青青青国产在线观看免费网站| 日韩在线观看视频免费| 久久亚洲AV无码精品色午夜麻豆 | 久久精品九九亚洲精品天堂| 国产免费AV片在线播放唯爱网| 一级人做人爰a全过程免费视频| 亚洲电影在线免费观看| 亚洲午夜国产片在线观看| 一个人看的www在线观看免费| 本免费AV无码专区一区| 亚洲av无码专区在线观看亚| 日韩精品一区二区亚洲AV观看| 免费大片在线观看网站| 免费影院未满十八勿进网站| 中文字幕一区二区免费| 美女裸免费观看网站| 亚洲综合校园春色| 亚洲男人第一av网站| 久久久久亚洲AV无码专区桃色| 日韩精品福利片午夜免费观着 | 亚洲一级特黄大片在线观看| 好男人看视频免费2019中文| 99re在线这里只有精品免费| 国产VA免费精品高清在线| 国产成人亚洲综合在线| 亚洲欧美日韩中文高清www777| 亚洲小说区图片区| 亚洲网站在线观看|