Java 有没有办法获得一个网站';使用Apache';什么是HttpClient?
有没有一种方法可以使用Apache的HttpClient(v4)获取网站的证书详细信息?我可以使用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
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());
希望这有帮助
希望这有帮助