Commit 6f15cce6 authored by Quxl's avatar Quxl

x

parent 7aa1835e
......@@ -40,8 +40,18 @@ public class SAPServiceFactory {
private String password;
public SAPServiceFactory() throws KeyManagementException, NoSuchAlgorithmException {
trustAllHttpsCertificates();
HttpsURLConnection.setDefaultHostnameVerifier(hv);
javax.net.ssl.TrustManager[] trustAllCerts = new javax.net.ssl.TrustManager[1];
javax.net.ssl.TrustManager tm = new MyTrustManager();
trustAllCerts[0] = tm;
javax.net.ssl.SSLContext sc = javax.net.ssl.SSLContext.getInstance("SSL");
sc.init(null, trustAllCerts, null);
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() {
public boolean verify(String urlHostName, SSLSession session) {
logger.warn("Warning: URL Host: " + urlHostName + " vs. " + session.getPeerHost());
return true;
}
});
}
public <T> T create(Class<T> requiredType, String WSDLPATH, QName serviceQName) {
......@@ -96,23 +106,7 @@ public class SAPServiceFactory {
PasswordText, PasswordNone, PasswordDigest
}
HostnameVerifier hv = new HostnameVerifier() {
public boolean verify(String urlHostName, SSLSession session) {
logger.warn("Warning: URL Host: " + urlHostName + " vs. " + session.getPeerHost());
return true;
}
};
private void trustAllHttpsCertificates() throws KeyManagementException, NoSuchAlgorithmException {
javax.net.ssl.TrustManager[] trustAllCerts = new javax.net.ssl.TrustManager[1];
javax.net.ssl.TrustManager tm = new miTM();
trustAllCerts[0] = tm;
javax.net.ssl.SSLContext sc = javax.net.ssl.SSLContext.getInstance("SSL");
sc.init(null, trustAllCerts, null);
javax.net.ssl.HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
}
static class miTM implements javax.net.ssl.TrustManager, javax.net.ssl.X509TrustManager {
public static class MyTrustManager implements javax.net.ssl.TrustManager, javax.net.ssl.X509TrustManager {
public java.security.cert.X509Certificate[] getAcceptedIssuers() {
return null;
}
......
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