title: How to ignore SSL error in Qt based TCP server - client application
body: <p>I am implementing client - server application that uses TCP for communication. I would like to use SSL to improve security, but I need to make it possible for client to connect even to servers with self signed or "not-very-secure" certificates. Right now I created some random test certificate and I am trying to use it on my local machine (both server and client runs there, no server host resolution can be done, it's simply localhost).</p>
  
  <p>I am keep on getting this error on client side:</p>
  
  <pre><code>Socket error: The host name did not match any of the valid hosts for this certificate
  </code></pre>
  
  <p>I am trying to suppress this by using this code:</p>
  
  <pre><code>    // We don't care about self signed certificates
      QList&lt;QSslError&gt; errors;
      errors &lt;&lt; QSslError(QSslError::SelfSignedCertificate);
      errors &lt;&lt; QSslError(QSslError::HostNameMismatch);
      ((QSslSocket*)this-&gt;socket)-&gt;ignoreSslErrors(errors);
      ((QSslSocket*)this-&gt;socket)-&gt;connectToHostEncrypted(this-&gt;hostname, this-&gt;port);
  </code></pre>
  
  <p>However it doesn't work, no matter if I use this code before or after connection, it still fails because of the "didn't match" error.</p>
  
  <p>How do I tell the <code>QSslSocket</code> "dear socket, I don't care at all if the certificate is self signed or doesn't match the valid host, just connect me please"?</p>