Return-Path: X-Original-To: apmail-hc-commits-archive@www.apache.org Delivered-To: apmail-hc-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id B1A05104BF for ; Fri, 3 May 2013 18:58:31 +0000 (UTC) Received: (qmail 58216 invoked by uid 500); 3 May 2013 18:58:31 -0000 Delivered-To: apmail-hc-commits-archive@hc.apache.org Received: (qmail 58184 invoked by uid 500); 3 May 2013 18:58:31 -0000 Mailing-List: contact commits-help@hc.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "HttpComponents Project" Delivered-To: mailing list commits@hc.apache.org Received: (qmail 58177 invoked by uid 99); 3 May 2013 18:58:31 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 03 May 2013 18:58:31 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 03 May 2013 18:58:29 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 7070B2388A29 for ; Fri, 3 May 2013 18:58:08 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1478926 - /httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientCustomSSL.java Date: Fri, 03 May 2013 18:58:08 -0000 To: commits@hc.apache.org From: olegk@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20130503185808.7070B2388A29@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: olegk Date: Fri May 3 18:58:08 2013 New Revision: 1478926 URL: http://svn.apache.org/r1478926 Log: Removed references to deprecated methods Modified: httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientCustomSSL.java Modified: httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientCustomSSL.java URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientCustomSSL.java?rev=1478926&r1=1478925&r2=1478926&view=diff ============================================================================== --- httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientCustomSSL.java (original) +++ httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientCustomSSL.java Fri May 3 18:58:08 2013 @@ -30,9 +30,12 @@ import java.io.File; import java.io.FileInputStream; import java.security.KeyStore; +import javax.net.ssl.SSLContext; + import org.apache.http.HttpEntity; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpGet; +import org.apache.http.conn.ssl.SSLContexts; import org.apache.http.conn.ssl.SSLSocketFactory; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; @@ -52,8 +55,15 @@ public class ClientCustomSSL { } finally { instream.close(); } + SSLContext sslcontext = SSLContexts.custom() + .loadTrustMaterial(trustStore) + .build(); + + SSLSocketFactory sslsf = new SSLSocketFactory(sslcontext, + SSLSocketFactory.BROWSER_COMPATIBLE_HOSTNAME_VERIFIER); CloseableHttpClient httpclient = HttpClients.custom() - .setSSLSocketFactory(new SSLSocketFactory(trustStore)).build(); + .setSSLSocketFactory(sslsf) + .build(); try { HttpGet httpget = new HttpGet("https://localhost/");