Qt and libQxt
-
Hello, I am trying to create a web service, with qt and libqxt. I could create an http server and it is working fine, but when I try set the conector with a https it does not work, the server start return true, but never came to the webevent and the web browser leave uploading. I have openssl installed and configured and I did a certificate with key and I am using.
Can anybody help me please. -
main.cpp :
@
#include "https.h"
#include <QtGui>
#include <QApplication>
#include <QxtSslServer>
#include <QSslKey>
#include <QSslCertificate>
#include <QxtSslServer>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
https w;
w.show();
QxtHttpsServerConnector conectar;
if( conectar.tcpServer()->autoEncrypt())
qDebug()<<"auto encript enabled";conectar.tcpServer()->setLocalCertificate("/usr/lib/ssl/mycert.pem"); conectar.tcpServer()->setPrivateKey("/usr/lib/ssl/mykey.pem"); //cheking certificate and key QSslCertificate mycer=conectar.tcpServer()->localCertificate(); QSslKey keycert=conectar.tcpServer()->privateKey (); qDebug()<<mycer.subjectInfo(QSslCertificate::Organization); qDebug()<<mycer.subjectInfo(QSslCertificate::CommonName); qDebug()<<mycer.subjectInfo(QSslCertificate::LocalityName); qDebug()<<mycer.subjectInfo(QSslCertificate::OrganizationalUnitName); qDebug()<<mycer.subjectInfo(QSslCertificate::CountryName); qDebug()<<mycer.subjectInfo(QSslCertificate::StateOrProvinceName);
if(keycert.isNull())
qDebug()<<"key doesnt work";
else
qDebug()<<"Key is ok";QxtHttpSessionManager *session=new QxtHttpSessionManager(); session->setPort(8080); session->setConnector(&conectar); myservice service(session); session->setStaticContentService(&service); if(session->start()) qDebug()<<"server is running"; conectar.tcpServer()->listen(QHostAddress::Any, 8080 ); if(conectar.tcpServer()->isListening()) qDebug()<<"esta listening"; qDebug()<<"error:" <<conectar.tcpServer()->errorString () <<" code: "<<conectar.tcpServer()->serverError () ; qDebug()<<"ip host: "<<conectar.tcpServer()->serverAddress (); return a.exec();
}
@
service.h :
@
#include <QxtHttpServerConnector>
#include <QxtHttpSessionManager>
#include <QxtWebSlotService>
#include <QxtWebPageEvent>
#include <QxtWebServiceDirectory>
#include <QxtAbstractWebSessionManager>
#include <QxtWebRequestEvent>
#include <QxtWebContent>
#include <QxtHttpsServerConnector>
#include <QFile>
class myservice : public QxtWebSlotService
{
Q_OBJECT;
public:
myservice(QxtAbstractWebSessionManager * sm, QObject * parent = 0 );
public slots:
void index(QxtWebRequestEvent* event);};
@service.cpp:
@
#include "service.h"myservice::myservice(QxtAbstractWebSessionManager * sm, QObject * parent ): QxtWebSlotService(sm,parent)
{
}void myservice::index(QxtWebRequestEvent* event)
{
qDebug()<<"llego aca";
postEvent(new QxtWebPageEvent(event->sessionID, event->requestID, "<h1>It Works!</h1>"));
}
@if in the main I chance QxtHttpsServerConnector conectar;
by QxtHttpServerConnector conectar; it works fine. else
the web browser do not finish of load. but I need https not http.
I need help please.