title: Qt 5.8 Apple Notification Server Handshake failed
body: <p>i tried it some ours now but i could not get it to work. I want to push some notifications from a Qt Application. Tried to get it to work on macOS Sierra with Qt 5.8 installation and on Pi3 also with Qt 5.8. </p>
  
  <p>I created my push certificate with "fastlane pem" and i tested it with "Pusher" and it works correct. But i cannot get it to work in Qt....</p>
  
  <p>At first is the code i use to initialize and connect the QSslSocket:</p>
  
  <pre><code>QSslSocket * ssl = new QSslSocket;
  
  connect(ssl, &amp;QSslSocket::encrypted, this, &amp;IOSPusher::encrypted );
  connect(ssl, static_cast&lt;void(QSslSocket::*)(const QList&lt;QSslError&gt; &amp;)&gt;(&amp;QSslSocket::sslErrors),this,&amp;IOSPusher::sslErrors);
  connect(ssl, static_cast&lt;void(QSslSocket::*)(QAbstractSocket::SocketError)&gt;(&amp;QSslSocket::error),this, &amp;IOSPusher::error );
  connect(ssl,&amp;QSslSocket::stateChanged,this,&amp;IOSPusher::stateChanged );
  </code></pre>
  
  <p>Loading the certificate</p>
  
  <pre><code>QString path = QStandardPaths::writableLocation(certificateLocation) + "/apns.pem";
  
  const auto certs =  QSslCertificate::fromPath(path);
  
  if(certs.count() &gt; 0){
      qDebug() &lt;&lt; "IOSPusher: Certificate loaded successfully";
  }else{
      qDebug() &lt;&lt; "Could not load certificate : " + path;
  }
  
  QSslConfiguration config = QSslConfiguration::defaultConfiguration();
  config.setCaCertificates(certs);
  
  ssl-&gt;setSslConfiguration(config);
  ssl-&gt;connectToHostEncrypted( gateway.sandbox.push.apple.com,2195 );
  </code></pre>
  
  <p>And thats the output i get:</p>
  
  <pre><code>IOSPusher: Certificate loaded successfully
  IOSPusher::stateChanged  QAbstractSocket::HostLookupState
  IOSPusher::stateChanged  QAbstractSocket::ConnectingState
  IOSPusher::stateChanged  QAbstractSocket::ConnectedState
  IOSPusher::error  QAbstractSocket::SocketError(13)
  IOSPusher::stateChanged  QAbstractSocket::ClosingState
  IOSPusher::stateChanged  QAbstractSocket::UnconnectedState
  </code></pre>
  
  <p>So according to the Qt documentation the error: </p>
  
  <blockquote>
    <p>QAbstractSocket::SocketError(13)</p>
  </blockquote>
  
  <p>means the following: </p>
  
  <blockquote>
    <p>SslHandshakeFailedError</p>
  </blockquote>
  
  <p>And </p>
  
  <p><del> > the SSL/TLS handshake failed and the encrypted channel could not be established. The sslErrors() signal should have been emitted.</p>
  
  <p><strong>But</strong> the <code>sslErrors()</code> signal will not be emitted in my case....
  </del></p>
  
  <blockquote>
    <p>The SSL/TLS handshake failed, so the connection was closed (only used in QSslSocket)</p>
  </blockquote>
  
  <p>Any ideas or samples how i can establish a encrypted connection to apple? </p>
  
  <p>Thanks in advance! </p>