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.
2 replies
main.cpp :
- #include "https.h"
- #include <QtGui>
- #include <QApplication>
- #include <QxtSslServer>
- #include <QSslKey>
- #include <QSslCertificate>
- #include <QxtSslServer>
- int main(int argc, char *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
- 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";
- 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:
- 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.
You must log in to post a reply. Not a member yet? Register here!


