Hi, I'm trying to connect to LDAP using a simple webservice call from an application deployed on a weblogic server. The error I am receiving is:
javax.net.ssl.SSLKeyException: FATAL Alert:BAD_CERTIFICATE - A corrupt or unuseable certificate was received.
at com.certicom.tls.interfaceimpl.TLSConnectionImpl.fireException(Unknown Source)
at com.certicom.tls.interfaceimpl.TLSConnectionImpl.fireAlertSent(Unknown Source)
at com.certicom.tls.record.handshake.HandshakeHandler.fireAlert(Unknown Source)
at com.certicom.tls.record.handshake.HandshakeHandler.handleHandshakeMessages(Unknown Source)
at com.certicom.tls.record.MessageInterpreter.interpretContent(Unknown Source)
at com.certicom.tls.record.MessageInterpreter.decryptMessage(Unknown Source)
at com.certicom.tls.record.ReadHandler.processRecord(Unknown Source)
...
The error happens when I call
OutputStream out = httpConn.getOutputStream(); on the following code:
private Document sendSoapMessage(
String request, String action, String task)
throws Exception {
//transfer request into byte array
byte[] b = request.getBytes();
// Create the connection where we're going to send the file.
URL url = new URL(LDAP_URL + task);
//create http url connection
// URLConnection connection = url.openConnection();
// HttpURLConnection httpConn = (HttpURLConnection) connection;
SSLAdapter adapter = SSLAdapterFactory.getDefaultFactory().getSSLAdapter();
HttpURLConnection httpConn = (HttpURLConnection) adapter.openConnection(url);
// Set the appropriate HTTP parameters.
httpConn.setRequestProperty("Content-Length", String.valueOf(b.length));
httpConn.setRequestProperty("Content-Type", "text/xml; charset=utf-8");
httpConn.setRequestProperty("SOAPAction", action);
httpConn.setRequestMethod("POST");
httpConn.setDoOutput(true);
httpConn.setDoInput(true);
httpConn.setRequestProperty("HOST", "10.84.10.170");
// Everything's set up; send the XML that was read in to b.
OutputStream out = httpConn.getOutputStream();
out.write( b );
out.close();
InputStream is = null;
try {
is = httpConn.getInputStream();
} catch (IOException e) {
is = httpConn.getErrorStream();
}
//TODO/////////////////////////////////////////////////////////
// Read the response and write it to standard out.
// InputStreamReader isr = new InputStreamReader(is, "UTF-8");
// BufferedReader in = new BufferedReader(isr);
// String inputLine;
// while ((inputLine = in.readLine()) != null)
// System.out.println(inputLine);
// in.close();
///////////////////////////////////////////////////////////
// Read the response
DOMParser parser = new DOMParser();
InputSource source = new InputSource(is);
parser.parse(source);
//cleanup
is.close();
httpConn.disconnect();
//return the information
return parser.getDocument();
}
The funny thing is, this same piece of code works if I put it in a simple
java harness, but does not work when I deploy it to the weblogic server. I'm a noob when it comes to SSL connections and whatnot, and this problem is killing me! I would appreciate ANY help!
Thank you!
Steve