PDA

View Full Version : Qssl



tpthyd
4th March 2009, 05:52
hi,
i have to download files from server. for that i am trying with qt exaples (../examples../ http) code. but i am unable to download. i came to knew that i have to configure SSL. i have searched for examples in internet, but ididn't found. can anyone help me how to solve my problem so that i'll be thankful to you.

spirit
4th March 2009, 06:15
did you build Qt with OpenSSL?

tpthyd
4th March 2009, 07:19
thanks for u r quick reply. i am using qt buitin example code for downloading files from server. it is downloading from some servers but for some urls it is showing message as unknown protocol. i knew that server has SSL and also authentication required. now i think problem is clear for u.

faldzip
4th March 2009, 08:25
I suppose that you have build Qt by your own from source. So when doing this you have to clearly configure built for OpenSSL if you want to use QSsl* classes. Examples are also built on your system with your own Qt, so if you dont have SSL in your Qt build then SSL is not available in examples. And this is probably your case. So, as spirit said:

did you build Qt with OpenSSL?

spirit
4th March 2009, 08:27
yup, exactly. :)

tpthyd
4th March 2009, 09:14
first of all, i don't know whether this is the solution for my problem or not. my problem is i am not able to download files from appache server which has SSL communicatio and i am able to downlaod files from some other servers. that's why i am asking Qssl may be prevent my problem. is it correct approach?

spirit
4th March 2009, 09:19
if server uses ssl connection then you have to use QSsl* classes and for using them you have to build Qt with OpenSSL.

faldzip
4th March 2009, 10:23
Here is a part of httpwindow.cpp from Qt Examples:


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

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


as you see it's surrounded by


#ifndef QT_NO_OPENSSL
// . . .
#endif


so if you compile Qt without SSL support then this example still work but can't handle SSL connections (QT_NO_OPENSSL will be defined so that code would be, let's say, cut out). You said that you need to download files from server with SSL - and it's not working, but it's working for non-SSL connections, so the reason would be in QT_NO_OPENSSL is defined == Qt built without OpenSSL.

faldzip
4th March 2009, 10:37
What's more, same thing you can see in qsslsocket.h:


#ifndef QT_NO_OPENSSL

class QDir;
class QSslCipher;
class QSslCertificate;
class QSslConfiguration;

class QSslSocketPrivate;
class Q_NETWORK_EXPORT QSslSocket : public QTcpSocket
{
// . . .
};

#endif // QT_NO_OPENSSL


So there is no class QSslSocket if you didn't build your Qt with OpenSSL.

tpthyd
5th March 2009, 04:46
that mean if i build qt with openssl , can i download files from server with out change of http example program..(../qt/4.4.1/examples/network/http).

i am new to qt. could u plz tell me how to buid qt with openssl?

spirit
5th March 2009, 06:26
yes, there is no needed to change your example, just rebuild it.
there are to options how to build it:
-- download sources (www.openssl.org) and then build them.
-- download www.openssl.org/related/binaries.html (www.openssl.org).

the second option is easier.
then all you need it's set environment variables for OpenSSL.


SET LIB=D:\develop\OpenSSL\lib\VC;%LIB% -- if you use MS VS or
SET LIB=D:\develop\OpenSSL\lib\MinGW;%LIB% -- if you use MinGW
SET INCLUDE=D:\develop\OpenSSL\include;%INCLUDE%


the next step -- you need to configure your Qt.
there are to configure options:


-openssl ........... Compile in run-time OpenSSL support
-openssl-linked .... Compile in linked OpenSSL support


I preferred then first option.
that's all.

tpthyd
6th March 2009, 11:20
thank you very much, thanks a lot for u r great infromation. i'll try as u told

srikanth_trulyit
15th June 2009, 08:48
Hi,

Im also facing the similar problem from a couple of days. I want to set openssl support for qt 4.5 on winxp sp2 machine

I configured as
configure -openssl -I C:\OpenSSL\include\openssl -L C:\OpenSSL\lib\MinGW -webkit

then did mingw32-make

still i get errors when make is done on ssl folder of qt
meanwhile after configure is done, if i open makefile in C:\Qt\2009.01\qt, it still doest show openssl includes and libs i supplied with configure.

Im a newbie and im facing this issue for quite some time now.
Kindly let me know where im getting wrong. I followed the above mentioned steps (previous posts)
Please provide me exact steps of building qt 4.5 with openssl.

Thanks,
Srikanth

spirit
15th June 2009, 08:55
try to set path to OpenSSL includes using


SET INCLUDE=D:\develop\OpenSSL\include;%INCLUDE%
not using
configure -openssl -I C:\OpenSSL\include\openssl -L C:\OpenSSL\lib\MinGW.

srikanth_trulyit
15th June 2009, 08:56
Hi,

Im also facing the similar problem from a couple of days. I want to set openssl support for qt 4.5 on winxp sp2 machine

I configured as
configure -openssl -I C:\OpenSSL\include\openssl -L C:\OpenSSL\lib\MinGW -webkit

then did mingw32-make

still i get errors when make is done on ssl folder of qt
meanwhile after configure is done, if i open makefile in C:\Qt\2009.01\qt, it still doest show openssl includes and libs i supplied with configure.

Im a newbie and im facing this issue for quite some time now.
Kindly let me know where im getting wrong. I followed the above mentioned steps (previous posts)
Please provide me exact steps of building qt 4.5 with openssl.

Thanks,
Srikanth

srikanth_trulyit
15th June 2009, 08:58
UPDATE:
i paste here some errors when mingw32-make is executed after configure


ssl\qsslcertificate.cpp:441: error: `X509_PUBKEY' undeclared (first use this fun
ction)
ssl\qsslcertificate.cpp:441: error: `xkey' undeclared (first use this function)
ssl\qsslcertificate.cpp:441: error: invalid use of undefined type `struct x509_s
t'
../../include/QtNetwork/../../src/network/ssl/qsslcertificate.h:52: error: forwa
rd declaration of `struct x509_st'
ssl\qsslcertificate.cpp:442: error: `EVP_PKEY' undeclared (first use this functi
on)
ssl\qsslcertificate.cpp:442: error: `pkey' undeclared (first use this function)
ssl\qsslcertificate.cpp:442: error: `q_X509_PUBKEY_get' undeclared (first use th
is function)
ssl\qsslcertificate.cpp:445: error: `EVP_PKEY_RSA' undeclared (first use this fu
nction)
ssl\qsslcertificate.cpp:446: error: 'class QSslKeyPrivate' has no member named '
rsa'
ssl\qsslcertificate.cpp:446: error: `q_EVP_PKEY_get1_RSA' undeclared (first use
this function)
ssl\qsslcertificate.cpp:449: error: `EVP_PKEY_DSA' undeclared (first use this fu
nction)
ssl\qsslcertificate.cpp:450: error: 'class QSslKeyPrivate' has no member named '
dsa'
ssl\qsslcertificate.cpp:450: error: `q_EVP_PKEY_get1_DSA' undeclared (first use
this function)
ssl\qsslcertificate.cpp:453: error: `EVP_PKEY_DH' undeclared (first use this fun
ction)
ssl\qsslcertificate.cpp:459: error: `q_EVP_PKEY_free' cannot be used as a functi
on
ssl\qsslcertificate.cpp: In static member function `static QSslCertificate QSslC
ertificatePrivate::QSslCertificate_from_X509(X509* )':
ssl\qsslcertificate.cpp:666: error: `q_X509_get_issuer_name' undeclared (first u
se this function)
ssl\qsslcertificate.cpp:666: error: `q_X509_NAME_oneline' cannot be used as a fu
nction
ssl\qsslcertificate.cpp:668: error: `q_X509_get_subject_name' undeclared (first
use this function)
ssl\qsslcertificate.cpp:668: error: `q_X509_NAME_oneline' cannot be used as a fu
nction
ssl\qsslcertificate.cpp:670: error: `ASN1_TIME' undeclared (first use this funct
ion)
ssl\qsslcertificate.cpp:670: error: `nbef' undeclared (first use this function)
ssl\qsslcertificate.cpp:670: error: `X509_get_notBefore' undeclared (first use t
his function)
ssl\qsslcertificate.cpp:671: error: `naft' undeclared (first use this function)
ssl\qsslcertificate.cpp:671: error: `X509_get_notAfter' undeclared (first use th
is function)
mingw32-make[2]: *** [tmp/obj/debug_shared/qsslcertificate.o] Error 1
mingw32-make[2]: Leaving directory `C:/Qt/2009.02/qt/src/network'
mingw32-make[1]: *** [debug-all] Error 2
mingw32-make[1]: Leaving directory `C:/Qt/2009.02/qt/src/network'
mingw32-make: *** [sub-network-make_default-ordered] Error 2

srikanth_trulyit
15th June 2009, 09:53
Hi spirit,

Thanks for the reply, I did as you mentioned.

added include path to INCLUDE and executed configure as

configure -openssl -L C:\OpenSSL\lib\MinGW -webkit

when im done with configure, i executed mingw32-make ans i still get those compilation errors as i mentioned. I still dont see any openssl rules in makefile

Thanks,
Srikanth