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

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

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

    少年阿賓

    那些青春的歲月

      BlogJava :: 首頁(yè) :: 聯(lián)系 :: 聚合  :: 管理
      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 閱讀(1932) 評(píng)論(1)  編輯  收藏 所屬分類: httpClient

    Feedback

    # re: Java HTTPS Client – HttpsURLConnection Example 2014-09-27 21:55 help
    把地址改為https://member.my089.com/,程序報(bào)錯(cuò),是什么原因呢  回復(fù)  更多評(píng)論
      

    主站蜘蛛池模板: 亚洲av永久无码精品古装片| 免费高清小黄站在线观看| 成人免费视频国产| 亚洲不卡影院午夜在线观看| 成人黄软件网18免费下载成人黄18免费视频| 日韩精品一区二区亚洲AV观看| 色猫咪免费人成网站在线观看 | 成全视频免费观看在线看| 美腿丝袜亚洲综合| 精品一区二区三区免费观看| 亚洲国产婷婷综合在线精品| 大片免费观看92在线视频线视频| 午夜亚洲国产成人不卡在线| xxxxx做受大片在线观看免费| 在线亚洲精品福利网址导航| 免费无码又爽又刺激一高潮| 久久狠狠高潮亚洲精品| 中文字幕无码不卡免费视频| 亚洲国产无线乱码在线观看 | 亚洲日韩一页精品发布| 毛片在线全部免费观看| 亚洲精品国产手机| 最新猫咪www免费人成| 在线播放亚洲精品| 亚洲精品无码专区久久久 | 国产真人无码作爱视频免费| 97亚洲熟妇自偷自拍另类图片| 在线观看H网址免费入口| 婷婷亚洲综合一区二区| 亚洲一区无码中文字幕 | 蜜臀91精品国产免费观看| 免费在线观看一区| 亚洲爆乳无码专区| 成年人性生活免费视频| 国产免费牲交视频免费播放| 亚洲视频日韩视频| 亚洲JIZZJIZZ中国少妇中文| 无码一区二区三区免费| 亚洲国产一区二区三区在线观看| 亚洲人成77777在线播放网站| 免费可以看黄的视频s色|