Hey
i m using jakarta common-httpclient to connect to a secure site for some stuff. The problem is that, i m behind the proxy which results in the follwing error. ::
:
javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: No trusted certificate found
at com.sun.net.ssl.internal.ssl.BaseSSLSocketImpl.a(Unknown Source)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.a(Unknown Source)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.a(Unknown Source)
at com.sun.net.ssl.internal.ssl.SunJSSE_az.a(Unknown Source)
- >
The same code if i m runnig whithout using a proxy works fine. Can anyone please help me out how to resolve this certification problem , when i m trying to connect to a URL from behind the proxy.
Please find the Code below. :
-------------------------------------------
import java.io.IOException;
import org.apache.commons.httpclient.HostConfiguration;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.PostMethod;
public class HttpsClientTest {
public static void main(
String args[]) throws Exception
{
testHttpClient();
}
protected static void testHttpClient() throws IOException
{
HostConfiguration hostConfig = new HostConfiguration();
hostConfig.setProxy("proxy i.p address", port number);
hostConfig.setHost("uri", defualt ssl port number);
HttpClient httpsClient = new HttpClient();
httpsClient.setHostConfiguration(hostConfig);
PostMethod httpsPost = new PostMethod("url");
//HttpConnection httpConnection = new HttpConnection();
httpsPost.setFollowRedirects(true);
httpsClient.executeMethod(httpsPost);
String response = httpsPost.getResponseBodyAsString();
System.out.println("The Reponse is " + response);
}
}
Looking for a quick response
Thanks