-2

Possible Duplicate:
How do I accept a self-signed certificate with a Java HttpsURLConnection?

I have set up a HTTP GET.

The code is as follows:

public class GetMethodEx {

public String getInternetData() throws Exception{       

        BufferedReader in = null;
        String data = null;
        try
        {
            HttpClient client = new DefaultHttpClient();
            URI website = new URI("http://www.google.com");
            HttpGet request = new HttpGet();
            request.setURI(website);
            HttpResponse response = client.execute(request);
            in = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
            StringBuffer sb = new StringBuffer("");
            String l = "";
            String nl = System.getProperty("line.separator");
            while ((l = in.readLine()) !=null){
                sb.append(l + nl);
            }
            in.close();
            data = sb.toString();
            return data;        
        } finally{
            if (in != null){
                try{
                    in.close();
                    return data;
                }catch (Exception e){
                    e.printStackTrace();
                }
            }
        }
}

}

The code allows me to retrieve any http websites, that I assume signed certificates.

However, when I try to retrieve a request from my self-signed server. I get no response.

Community
  • 1
  • 1
Lyanor Roze
  • 111
  • 1
  • 1
  • 7

1 Answers1

0

To resume, you could use one of those two answers and this will resolve your problem:

It is easy to fix your problem.

Community
  • 1
  • 1
Milos Cuculovic
  • 19,631
  • 51
  • 159
  • 265