11

I have a Qt QWebKit based application that needs to use HTTPS to talk to web pages. I have downloaded the QtSDK, as well as the OpenSSL binaries (from here).

My problem lies in deploying my application. I have copied the relevant Qt DLL files, as well as the relevant OpenSSL DLL files (libeay32.dll and ssleay32.dll) into my application directory, but when I try to access HTTPS web pages from within my application it fails! The application doesn't crash, but the page is blank. Regular HTTP pages work perfectly fine.

It's clear that there's an error with how I'm distributing OpenSSL with my application, I'm just not sure where I'm going wrong.

I'd really not like to bundle the OpenSSL installer with my application.

  • 1
    Are you certain you're checking OpenSSL error returns at all call sites and potentially logging or otherwise showing unexpected error results? I could easily imagine a missing certificate store or invalid date/time on a system causing certificate chain validation errors that might not pop up during "normal" testing... – sarnold Feb 03 '12 at 00:44
  • This is a good point. I have read elsewhere that unhandled OpenSSL errors can cause the loading of HTTPS pages to halt. In my case I was handling all OpenSSL errors (by ignoring them), but the error handler was never called by my QNetworkManager. – Anson MacKeracher Feb 08 '12 at 23:19

2 Answers2

6

Hello anybody reading this trying to debug similar issues. The problem was that the OpenSSL DLL binaries distributed by Shining Light Productions require the Visual C++ redistributables to function properly.

To distribute OpenSSL DLLs with your application without having to also distribute the Visual C++ Redistributables, you can compile OpenSSL yourself using MinGW. The instructions for compiling OpenSSL with MinGW are included in the OpenSSL source distribution.

You may need to distribute the MinGW DLL with your application if you do this. This wasn't a problem for me since I compiled by Qt application with MinGW in the first place.

2

Can try to ignore the ssl certificate ?

Header file :

void sslErrors(QNetworkReply*,const QList<QSslError> &errors);

Constructor :

 connect(&qnam, SIGNAL(sslErrors(QNetworkReply*,QList<QSslError>)),
         this, SLOT(sslErrors(QNetworkReply*,QList<QSslError>)));

Method definition :

void HttpWindow::sslErrors(QNetworkReply *reply, const QList<QSslError> &errors)
{
 QString errorString;
 foreach (const QSslError &error, errors) {
     if (!errorString.isEmpty())
         errorString += ", ";
     errorString += error.errorString();
 }

 if (QMessageBox::warning(this, tr("HTTP"),
                          tr("One or more SSL errors has occurred: %1").arg(errorString),
                          QMessageBox::Ignore | QMessageBox::Abort) == QMessageBox::Ignore) {
     reply->ignoreSslErrors();
 }
}

For more information , kindly see your QT HTTP example.

Community
  • 1
  • 1
Siva Karuppiah
  • 995
  • 1
  • 8
  • 17
  • This is a good point. Everybody should handle the SSL errors if they intend to use HTTPS in a QWebView. This was not the source of my problem, but it is good advice regardless! – Anson MacKeracher Feb 08 '12 at 23:20