Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/321.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 有没有办法获得一个网站';使用Apache';什么是HttpClient?_Java_Apache Httpclient 4.x - Fatal编程技术网

Java 有没有办法获得一个网站';使用Apache';什么是HttpClient?

Java 有没有办法获得一个网站';使用Apache';什么是HttpClient?,java,apache-httpclient-4.x,Java,Apache Httpclient 4.x,有没有一种方法可以使用Apache的HttpClient(v4)获取网站的证书详细信息?我可以使用javax.net.ssl.HttpsURLConnection.getServerCertificates()获取网站的证书,但是我使用Apache的连接,并且希望使用相同的库 我需要证书的颁发者、到期日、算法等信息 DefaultHttpClient httpclient = new DefaultHttpClient(); httpclient.addRequestInterceptor(ne

有没有一种方法可以使用Apache的HttpClient(v4)获取网站的证书详细信息?我可以使用
javax.net.ssl.HttpsURLConnection.getServerCertificates()
获取网站的证书,但是我使用Apache的连接,并且希望使用相同的库

我需要证书的颁发者、到期日、算法等信息

DefaultHttpClient httpclient = new DefaultHttpClient();
httpclient.addRequestInterceptor(new HttpRequestInterceptor() {

    public void process(
            HttpRequest request, HttpContext context) throws HttpException, IOException {
        HttpRoutedConnection conn = (HttpRoutedConnection) context.getAttribute(
                ExecutionContext.HTTP_CONNECTION);
        SSLSession sslsession = conn.getSSLSession();
        if (sslsession != null) {
            // Do something useful with the SSL session details
            // and if necessary stick the result to the execution context
            // for further processing
            X509Certificate[] certs = sslsession.getPeerCertificateChain();
            for (X509Certificate cert: certs) {
                System.out.println(cert);
            }
        }
    }
});
HttpResponse response = httpclient.execute(new HttpGet("https://verisign.com/"));
EntityUtils.consume(response.getEntity());
希望这有帮助

希望这有帮助