在java中,使用DefaultHttpClient访问https下的链接,
DefaultHttpClient client = new DefaultHttpClient();
会有一个异常 javax.net.ssl.SSLHandshakeException:,这个异常则是https的安全认证所引发的。怎么来绕过安全认证实现访问https的链接呢?
直接上代码:
import java.io.IOException;
import java.net.Socket;
import java.net.UnknownHostException;
import java.security.KeyManagementException;
import java.security.KeyStore;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.UnrecoverableKeyException;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import org.apache.