title: Issue with SSL certificate: "No peer certificate"
body: <p>I'm trying to authenticate through <a href="http://www.last.fm/api/mobileauth" rel="nofollow noreferrer">Last.fm's API</a>.</p>
  
  <p>On Android 4.3 it works just by doing</p>
  
  <pre><code>HttpPost post = new HttpPost("https://ws.audioscrobbler.com/2.0/");
  post.setEntity(new UrlEncodedFormEntity(params));
  
  HttpClient client = new DefaultHttpClient();
  HttpResponse response = client.execute(post);
  </code></pre>
  
  <p>but on 2.3.3 I get</p>
  
  <pre><code>javax.net.ssl.SSLPeerUnverifiedException: No peer certificate
  </code></pre>
  
  <p>Then I tried the solution given <a href="https://stackoverflow.com/a/3904473/326849">here</a>:</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);
  DefaultHttpClient httpClient = new DefaultHttpClient(mgr, client.getParams());
  
  // Set verifier     
  HttpsURLConnection.setDefaultHostnameVerifier(hostnameVerifier);        
  
  HttpPost post = new HttpPost("https://ws.audioscrobbler.com/2.0/");
  post.setEntity(new UrlEncodedFormEntity(params));
  
  HttpResponse response = httpClient.execute(post);
  </code></pre>
  
  <p>but I still get the same error.</p>
  
  <p>Then I tried <a href="https://stackoverflow.com/a/17159839/326849">that</a>:</p>
  
  <pre><code>HttpParams httpParams = new BasicHttpParams();
  HttpProtocolParams.setVersion(httpParams, HttpVersion.HTTP_1_1);
  HttpProtocolParams.setContentCharset(httpParams, HTTP.DEFAULT_CONTENT_CHARSET);
  HttpProtocolParams.setUseExpectContinue(httpParams, true);
  
  SchemeRegistry schReg = new SchemeRegistry();
  schReg.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
  schReg.register(new Scheme("https", SSLSocketFactory.getSocketFactory(), 443));
  ClientConnectionManager conMgr = new ThreadSafeClientConnManager(httpParams, schReg);
  
  DefaultHttpClient httpClient = new DefaultHttpClient(conMgr, httpParams);
  
  HttpPost post = new HttpPost("https://ws.audioscrobbler.com/2.0/");
  post.setEntity(new UrlEncodedFormEntity(params));
  
  HttpResponse response = httpClient.execute(post);
  </code></pre>
  
  <p>and failed again.</p>
  
  <p>Anybody can help?</p>