Catch SSL errors in example
authorKurt Pattyn <pattyn.kurt@gmail.com>
Sun, 16 Feb 2014 13:01:28 +0000 (14:01 +0100)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Sun, 16 Feb 2014 13:44:35 +0000 (14:44 +0100)
Change-Id: Ib9a399789878030361d9bdddd8dbfbb1832cf756
Reviewed-by: Kurt Pattyn <pattyn.kurt@gmail.com>
examples/sslechoserver/sslechoserver.cpp
examples/sslechoserver/sslechoserver.h

index 53f5066..9b35f15 100644 (file)
@@ -78,6 +78,8 @@ SslEchoServer::SslEchoServer(quint16 port, QObject *parent) :
         qDebug() << "SSL Echo Server listening on port" << port;
         connect(m_pWebSocketServer, &QWebSocketServer::newConnection,
                 this, &SslEchoServer::onNewConnection);
+        connect(m_pWebSocketServer, &QWebSocketServer::sslErrors,
+                this, &SslEchoServer::onSslErrors);
     }
 }
 //! [constructor]
@@ -138,4 +140,9 @@ void SslEchoServer::socketDisconnected()
         pClient->deleteLater();
     }
 }
+
+void SslEchoServer::onSslErrors(const QList<QSslError> &)
+{
+    qDebug() << "Ssl errors occurred";
+}
 //! [socketDisconnected]
index b2ac3f7..84dfeab 100644 (file)
@@ -44,6 +44,7 @@
 #include <QtCore/QObject>
 #include <QtCore/QList>
 #include <QtCore/QByteArray>
+#include <QtNetwork/QSslError>
 
 QT_FORWARD_DECLARE_CLASS(QWebSocketServer)
 QT_FORWARD_DECLARE_CLASS(QWebSocket)
@@ -62,6 +63,7 @@ private Q_SLOTS:
     void processTextMessage(QString message);
     void processBinaryMessage(QByteArray message);
     void socketDisconnected();
+    void onSslErrors(const QList<QSslError> &errors);
 
 private:
     QWebSocketServer *m_pWebSocketServer;