Commit 74930ed8 authored by Quxl's avatar Quxl

x

parent 7700a15d
...@@ -5,7 +5,9 @@ import java.security.NoSuchAlgorithmException; ...@@ -5,7 +5,9 @@ import java.security.NoSuchAlgorithmException;
import javax.net.ssl.HostnameVerifier; import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection; import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession; import javax.net.ssl.SSLSession;
import javax.net.ssl.TrustManager;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
...@@ -15,11 +17,8 @@ public class SAPTrustManager implements javax.net.ssl.TrustManager, javax.net.ss ...@@ -15,11 +17,8 @@ public class SAPTrustManager implements javax.net.ssl.TrustManager, javax.net.ss
private final static Log logger = LogFactory.getLog(SAPTrustManager.class); private final static Log logger = LogFactory.getLog(SAPTrustManager.class);
public static void trustAllHttpsCertificates() throws NoSuchAlgorithmException, KeyManagementException { public static void trustAllHttpsCertificates() throws NoSuchAlgorithmException, KeyManagementException {
javax.net.ssl.TrustManager[] trustAllCerts = new javax.net.ssl.TrustManager[1]; SSLContext sc = SSLContext.getInstance("SSL");
javax.net.ssl.TrustManager tm = new SAPTrustManager(); sc.init(null, new TrustManager[] {new SAPTrustManager()}, null);
trustAllCerts[0] = tm;
javax.net.ssl.SSLContext sc = javax.net.ssl.SSLContext.getInstance("SSL");
sc.init(null, trustAllCerts, null);
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory()); HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() { HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() {
public boolean verify(String urlHostName, SSLSession session) { public boolean verify(String urlHostName, SSLSession session) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment