Turns out that the problem is not with the SSL. But, the authentication cookie 
stops getting accepted on the service side after a while (I couldnt set a 
pattern on how long it takes). The same cookie works if I send it from 
standalone java code. My suspicion is on the fact that connections are pooled. 
And I have a feeling that there is some residue of previous requests are 
retained in the connection objects and are causing this to fail.

Is that possible scenario? If so, are there any ways to make sure the 
connection is completely cleaned up and does not have any carry over from one 
request to another, using the same connection.

Any help will be really appreciated.

Thanks,
Arul




________________________________
From: Arul Govindarajan <[EMAIL PROTECTED]>
To: [email protected]
Sent: Thursday, December 11, 2008 1:08:33 AM
Subject: HTTP URL results in SSLHandshake error

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();
        }


      

Reply via email to