I am working to correct an issue with some older Java app code that has to be able to run in a Java 1.4 app server.
The app is calling a SOAP WebService and must pass a client certificate. The app is sharing a server with a number of other apps, so I am attempting to use custom key managers to make the connection. The code below works in newer versions of Java, but the 'setDefault' was introduced in 1.6. It is causing a cannot find symbol error when I try to compile it.
javax.net.ssl.SSLContext context = javax.net.ssl.SSLContext.getInstance("SSL");
context.init(getKeyManagers(), (TrustManager[]) getKeyManagers(), null);
SSLContext.setDefault(context);
So, in Java 1.4 what would be the equivalent of "SSLContext.setDefault(context);"?
Thanks, Doug
Here is additional code for what I am trying to do:
private org.apache.axis.message.SOAPEnvelope SendSOAP(String SOAPaction,
String EndPointURL, String SOAPmessage) {
TrustManager[] trustAllCerts = new TrustManager[] { new X509TrustManager() {
public X509Certificate[] getAcceptedIssuers() {
// TODO Auto-generated method stub
return null;
}
public void checkServerTrusted(X509Certificate[] arg0, String arg1)
throws CertificateException {
// TODO Auto-generated method stub
}
public void checkClientTrusted(X509Certificate[] arg0, String arg1)
throws CertificateException {
// TODO Auto-generated method stub
}
} };
try {
SSLContext context = SSLContext.getInstance("SSL");
context.init(getKeyManagers(), trustAllCerts, null);
SSLContext.setDefault(context);
} catch (Exception e) {
logger.fatal(e.toString());
}
org.apache.axis.message.SOAPEnvelope resp = null;
try {
InputStream input = new ByteArrayInputStream(SOAPmessage.getBytes());
org.apache.axis.client.Service service = new org.apache.axis.client.Service();
logger.debug(SOAPmessage);
Call call = (Call) service.createCall();
call.setSOAPActionURI(SOAPaction);
call.setTargetEndpointAddress(new URL(EndPointURL));
SOAPEnvelope env = new SOAPEnvelope(input);
resp = call.invoke(env);
} catch (Exception e) {
e.printStackTrace();
logger.fatal("Exception from send soap: " + e.toString());
e.printStackTrace(System.out);
}
return resp;
}