Hi,
I am using HttpClient 3.1 for an application that calls a service. This
application takes the cookie from the original request and passes it on to the
service to enable (use) SSO. I am accessing the service thru HTTP (no SSL).
However, I am running into this exception....
javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException:
Certificate not Trusted
I am not sure how a HTTP url goes into, seemingly, HTTPS. Any clues or
workarounds to resolve this issue?
Thanks,
Arul
Here is excerpts from my code...
connectionManager =
new MultiThreadedHttpConnectionManager();
connectionManager.getParams().setMaxTotalConnections(30);
client = new HttpClient(connectionManager);
GetMethod method = new GetMethod(url);
method.setFollowRedirects(false);
method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER,
new DefaultHttpMethodRetryHandler(0, false));
method.setRequestHeader("Cookie", cookie);
try
{
long startTime = System.currentTimeMillis();
int statusCode = client.executeMethod(method);
logger.info(method.getURI() + " took "
+ (System.currentTimeMillis() -
startTime) + " ms");
if (statusCode != HttpStatus.SC_OK) {
logger.error("Failed: " +
method.getStatusLine() + " : " + url);
}
String responseBody = method.getResponseBodyAsString();
if(statusCode == HttpStatus.SC_OK)
{
res = responseBody;
}
else
{
throw new
Exception(String.valueOf(method.getStatusCode()) + method.getStatusText());
}
}
catch (HttpException he)
{
logger.error("Fatal error: " + he.getMessage());
throw he;
}
catch (Exception e)
{
logger.error("Fatal error: " + e.getMessage());
throw e;
}
finally
{
// Release the connection.
method.releaseConnection();
}