diff --git a/src/tl/tl/tlHttpStreamQt.cc b/src/tl/tl/tlHttpStreamQt.cc index d0c368089..d97a0e8da 100644 --- a/src/tl/tl/tlHttpStreamQt.cc +++ b/src/tl/tl/tlHttpStreamQt.cc @@ -246,6 +246,7 @@ InputHttpStreamPrivateData::InputHttpStreamPrivateData (const std::string &url) s_auth_handler = new AuthenticationHandler (); connect (s_network_manager, SIGNAL (authenticationRequired (QNetworkReply *, QAuthenticator *)), s_auth_handler, SLOT (authenticationRequired (QNetworkReply *, QAuthenticator *))); connect (s_network_manager, SIGNAL (proxyAuthenticationRequired (const QNetworkProxy &, QAuthenticator *)), s_auth_handler, SLOT (proxyAuthenticationRequired (const QNetworkProxy &, QAuthenticator *))); + connect (s_network_manager, SIGNAL (sslErrors (QNetworkReply *, const QList &)), this, SLOT (sslErrors (QNetworkReply *, const QList &))); tl::StaticObjects::reg (&s_network_manager); tl::StaticObjects::reg (&s_auth_handler); @@ -346,6 +347,8 @@ InputHttpStreamPrivateData::issue_request (const QUrl &url) delete mp_buffer; mp_buffer = 0; + m_ssl_errors.clear (); + // remove old request (important for redirect) close (); @@ -462,13 +465,18 @@ InputHttpStreamPrivateData::read (char *b, size_t n) break; default: em = tl::to_string (QObject::tr ("Network API error")); + if (! m_ssl_errors.empty ()) { + em += tl::to_string (QObject::tr (" (with SSL errors: ")); + em += m_ssl_errors; + em += ")"; + } } ec = int (mp_reply->error ()); } QByteArray data = mp_reply->readAll (); - throw HttpErrorException (em, ec, tl::to_string (mp_reply->url ().toString ()), tl::to_string (data.constData (), (int)data.size ())); + throw HttpErrorException (em, ec, tl::to_string (mp_reply->url ().toString ()), tl::to_string (data.constData (), (int) data.size ())); } @@ -480,6 +488,20 @@ InputHttpStreamPrivateData::read (char *b, size_t n) return data.size (); } +void +InputHttpStreamPrivateData::sslErrors (QNetworkReply *, const QList &errors) +{ + // log SSL errors + for (QList::const_iterator e = errors.begin (); e != errors.end (); ++e) { + if (! m_ssl_errors.empty ()) { + m_ssl_errors += ", "; + } + m_ssl_errors += "\""; + m_ssl_errors += tl::to_string (e->errorString ()); + m_ssl_errors += "\""; + } +} + void InputHttpStreamPrivateData::reset () { diff --git a/src/tl/tl/tlHttpStreamQt.h b/src/tl/tl/tlHttpStreamQt.h index 1cc9b3ac7..a43609158 100644 --- a/src/tl/tl/tlHttpStreamQt.h +++ b/src/tl/tl/tlHttpStreamQt.h @@ -31,9 +31,9 @@ #include #include #include +#include #include -class QNetworkAccessManager; class QNetworkReply; class QNetworkProxy; class QAuthenticator; @@ -105,6 +105,7 @@ public: private slots: void finished (QNetworkReply *); void resend (); + void sslErrors (QNetworkReply *reply, const QList &errors); private: std::string m_url; @@ -116,6 +117,7 @@ private: std::map m_headers; tl::Event m_ready; QTimer *mp_resend_timer; + std::string m_ssl_errors; void issue_request (const QUrl &url); };