Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. 3rd Party Software
  4. Qt and libQxt

Qt and libQxt

Scheduled Pinned Locked Moved 3rd Party Software
3 Posts 2 Posters 3.6k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    luisaguirre4984
    wrote on 6 Mar 2012, 14:57 last edited by
    #1

    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.

    1 Reply Last reply
    0
    • M Offline
      M Offline
      miroslav
      wrote on 6 Mar 2012, 16:09 last edited by
      #2

      Without any source code, log files or other specific information there is not much we can do to help you. Can you provide a bit more information?

      Mirko Boehm | mirko@kde.org | KDE e.V.
      FSFE Fellow
      Qt Certified Specialist

      1 Reply Last reply
      0
      • L Offline
        L Offline
        luisaguirre4984
        wrote on 7 Mar 2012, 12:19 last edited by
        #3

        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&#40;&#41;;
        

        }

        @

        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.

        1 Reply Last reply
        0

        3/3

        7 Mar 2012, 12:19

        • Login

        • Login or register to search.
        3 out of 3
        • First post
          3/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved