title: SSLSocket on Android does not fail on certificate with invalid server name
body: <p>Here's the code I'm using to test the <code>SSLSocket</code> instances returned by <code>SSLCertificateSocketFactory</code> against <a href="https://badssl.com" rel="nofollow">https://badssl.com</a>:</p>
  
  <pre><code>SSLCertificateSocketFactory factory = (SSLCertificateSocketFactory) SSLCertificateSocketFactory.getDefault(0);
  mSocket = factory.createSocket();
  factory.setHostname(mSocket, host);
  mSocket.connect(new InetSocketAddress(host, 443), timeout);
  mInput = mSocket.getInputStream();
  mOutput = mSocket.getOutputStream();
  </code></pre>
  
  <p>This code works when connecting to <code>badssl.com:443</code>, throws an exception as expected when connecting to <code>expired.badssl.com:443</code> or <code>self-signed.badssl.com:443</code>, but <strong>does not throw</strong> when connecting to <code>wrong.host.badssl.com:443</code>.</p>
  
  <p>In case this makes a difference, note that all hostnames on <a href="https://badssl.com" rel="nofollow">https://badssl.com</a> appear to share a single IP, so configuring the <code>SSLSocket</code> for SNI is required.</p>
  
  <p>PS: This was observed on a Nexus 5 running Android 6.0.1.</p>