connect over ssl without certificate
<p>I'm trying to connect to my server over SSL port 443 without a certificate.</p>

<p>I'm getting an error thrown: </p>

<blockquote>
  <p>javax.net.ssl.SSLException: Not trusted server certificate</p>
</blockquote>

<p>Reading other questions to solve the problem, the following code should work, but I'm still getting the error message.  What could I be doing wrong?</p>

<pre><code>HostnameVerifier hostnameVerifier = org.apache.http.conn.ssl.SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER;
DefaultHttpClient client = new DefaultHttpClient();
SchemeRegistry registry = new SchemeRegistry();
SSLSocketFactory socketFactory = SSLSocketFactory.getSocketFactory();
socketFactory.setHostnameVerifier((X509HostnameVerifier) hostnameVerifier);
registry.register(new Scheme("https", socketFactory, 443));
SingleClientConnManager mgr = new SingleClientConnManager(client.getParams(), registry);
httpclient = new DefaultHttpClient(mgr, client.getParams());

// Set verifier     
HttpsURLConnection.setDefaultHostnameVerifier(hostnameVerifier);
HttpGet httpget = new HttpGet(this.requestedURL);
httpget.addHeader(new BasicScheme().authenticate(creds, httpget));

try
{
    response = httpclient.execute(httpget);
}
catch(java.lang.Throwable t) {}
</code></pre>
