title: Android No peer certificate DefaultHttpClient
body: <p>2 days I'm reading blog/answer/docs but no solution. I have a SimpleHosting on Gandi's servers with a SSL certificate <a href="https://auth.ruchers.net" rel="nofollow noreferrer">https://auth.ruchers.net</a></p>
  
  <p>As you can see, the certificate is valid.</p>
  
  <p>But when I try to connect to this page with my DefaultHttpClient class I receive a [No peer certificate] error. My code is the same as you can find here : <a href="http://blog.antoine.li/2010/10/22/android-trusting-ssl-certificates/" rel="nofollow noreferrer">http://blog.antoine.li/2010/10/22/android-trusting-ssl-certificates/</a></p>
  
  <p>I read here <a href="https://stackoverflow.com/questions/16130542/android-ssl-no-peer-certificate">Android SSL No peer certificate</a> and here <a href="https://stackoverflow.com/questions/8806128/android-ssl-no-peer-certificate">Android SSL - No Peer Certificate</a> that the problem could be the order of the certificate chain... Ok, let's go, I'll control the chain :</p>
  
  <pre><code>openssl s_client -connect auth.ruchers.net:443
  </code></pre>
  
  <p>return </p>
  
  <pre><code>... no peer certificate available ...
  </code></pre>
  
  <p>To have a correct answer I need to specifie the servername</p>
  
  <pre><code>openssl s_client -connect auth.ruchers.net:443 -servername auth.ruchers.net
  </code></pre>
  
  <p>How can I say to my SSLSocketFactory to use "auth.ruchers.net" as servername for this certificate ?</p>
  
  <p>Thank you for the help.</p>
  
  <p>Best Regards,
  Greg</p>