Commit 16a35925 authored by Quxl's avatar Quxl

x

parent 9d6ac3b1
...@@ -6,6 +6,8 @@ import java.io.IOException; ...@@ -6,6 +6,8 @@ import java.io.IOException;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
import java.security.KeyStore; import java.security.KeyStore;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
...@@ -13,6 +15,7 @@ import javax.net.ssl.KeyManager; ...@@ -13,6 +15,7 @@ import javax.net.ssl.KeyManager;
import javax.net.ssl.KeyManagerFactory; import javax.net.ssl.KeyManagerFactory;
import javax.net.ssl.TrustManager; import javax.net.ssl.TrustManager;
import javax.net.ssl.TrustManagerFactory; import javax.net.ssl.TrustManagerFactory;
import javax.net.ssl.X509TrustManager;
import javax.security.auth.callback.Callback; import javax.security.auth.callback.Callback;
import javax.security.auth.callback.CallbackHandler; import javax.security.auth.callback.CallbackHandler;
import javax.xml.namespace.QName; import javax.xml.namespace.QName;
...@@ -71,10 +74,9 @@ public class SAPServiceFactory { ...@@ -71,10 +74,9 @@ public class SAPServiceFactory {
HTTPConduit httpConduit = (HTTPConduit) client.getConduit(); HTTPConduit httpConduit = (HTTPConduit) client.getConduit();
TLSClientParameters tlsParams = httpConduit.getTlsClientParameters(); TLSClientParameters tlsParams = httpConduit.getTlsClientParameters();
tlsParams = tlsParams == null ? new TLSClientParameters() : tlsParams; tlsParams = tlsParams == null ? new TLSClientParameters() : tlsParams;
tlsParams.setSecureSocketProtocol(SSLProtocol);
tlsParams.setKeyManagers(getKeyManagers());
tlsParams.setTrustManagers(getTrustManagers());
httpConduit.setTlsClientParameters(tlsParams); httpConduit.setTlsClientParameters(tlsParams);
tlsParams.setTrustManagers(new TrustManager[] {new TrustAllManager() });
tlsParams.setDisableCNCheck(true);
} }
} }
return service; return service;
...@@ -110,10 +112,18 @@ public class SAPServiceFactory { ...@@ -110,10 +112,18 @@ public class SAPServiceFactory {
} }
private class TrustAllManager implements X509TrustManager {
public void checkClientTrusted(X509Certificate[] arg0, String arg1) throws CertificateException {}
public void checkServerTrusted(X509Certificate[] arg0, String arg1) throws CertificateException {}
public X509Certificate[] getAcceptedIssuers() {
return null;
}
}
private static TrustManager[] trustManagers = null; private static TrustManager[] trustManagers = null;
private static KeyManager[] keyManagers = null; private static KeyManager[] keyManagers = null;
private TrustManager[] getTrustManagers() { public TrustManager[] getTrustManagers() {
if(trustManagers == null) { if(trustManagers == null) {
FileInputStream fis = null; FileInputStream fis = null;
try { try {
...@@ -140,7 +150,7 @@ public class SAPServiceFactory { ...@@ -140,7 +150,7 @@ public class SAPServiceFactory {
return trustManagers; return trustManagers;
} }
private KeyManager[] getKeyManagers() { public KeyManager[] getKeyManagers() {
if(keyManagers == null) { if(keyManagers == null) {
FileInputStream fis = null; FileInputStream fis = null;
try { try {
......
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