Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I distribute OpenSSL with my Qt WebKit based application to Windows?

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.

like image 679
Anson MacKeracher Avatar asked Feb 03 '12 00:02

Anson MacKeracher


2 Answers

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.

like image 45
Siva Karuppiah Avatar answered Oct 08 '22 08:10

Siva Karuppiah


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.

like image 84
Anson MacKeracher Avatar answered Oct 08 '22 07:10

Anson MacKeracher