March 6, 2012

luisaguirre4984 luisaguirre4..
Lab Rat
6 posts

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

March 6, 2012

miroslav miroslav
Ant Farmer
228 posts

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?

 Signature 

Mirko Boehm | .(JavaScript must be enabled to view this email address) | KDE e.V.
FSFE Fellow
Qt Certified Specialist

March 7, 2012

luisaguirre4984 luisaguirre4..
Lab Rat
6 posts

main.cpp :

  1. #include "https.h"
  2. #include <QtGui>
  3. #include <QApplication>
  4. #include <QxtSslServer>
  5. #include <QSslKey>
  6. #include <QSslCertificate>
  7. #include <QxtSslServer>
  8. int main(int argc, char *argv[])
  9. {
  10.     QApplication a(argc, argv);
  11.     https w;
  12.     w.show();
  13.     QxtHttpsServerConnector conectar;
  14.   if( conectar.tcpServer()->autoEncrypt())
  15.      qDebug()<<"auto encript enabled";
  16.  
  17.     conectar.tcpServer()->setLocalCertificate("/usr/lib/ssl/mycert.pem");
  18.     conectar.tcpServer()->setPrivateKey("/usr/lib/ssl/mykey.pem");
  19.  
  20.     //cheking certificate and key
  21.     QSslCertificate mycer=conectar.tcpServer()->localCertificate();
  22.     QSslKey keycert=conectar.tcpServer()->privateKey ();
  23.  
  24.     qDebug()<<mycer.subjectInfo(QSslCertificate::Organization);
  25.     qDebug()<<mycer.subjectInfo(QSslCertificate::CommonName);
  26.     qDebug()<<mycer.subjectInfo(QSslCertificate::LocalityName);
  27.     qDebug()<<mycer.subjectInfo(QSslCertificate::OrganizationalUnitName);
  28.     qDebug()<<mycer.subjectInfo(QSslCertificate::CountryName);
  29.     qDebug()<<mycer.subjectInfo(QSslCertificate::StateOrProvinceName);
  30.    if(keycert.isNull())
  31.      qDebug()<<"key doesnt work";
  32.     else
  33.      qDebug()<<"Key is ok";
  34.  
  35.     QxtHttpSessionManager *session=new QxtHttpSessionManager();
  36.     session->setPort(8080);
  37.     session->setConnector(&conectar);
  38.     myservice service(session);
  39.     session->setStaticContentService(&service);
  40.     if(session->start())
  41.      qDebug()<<"server is running";
  42.  
  43.     conectar.tcpServer()->listen(QHostAddress::Any, 8080 );
  44.  
  45.     if(conectar.tcpServer()->isListening())
  46.      qDebug()<<"esta listening";
  47.     qDebug()<<"error:" <<conectar.tcpServer()->errorString () <<" code: "<<conectar.tcpServer()->serverError () ;
  48.     qDebug()<<"ip host: "<<conectar.tcpServer()->serverAddress ();
  49.     return a.exec();
  50. }
  51.  
  52.    

service.h :

  1. #include <QxtHttpServerConnector>
  2. #include <QxtHttpSessionManager>
  3. #include <QxtWebSlotService>
  4. #include <QxtWebPageEvent>
  5. #include <QxtWebServiceDirectory>
  6. #include <QxtAbstractWebSessionManager>
  7. #include <QxtWebRequestEvent>
  8. #include <QxtWebContent>
  9. #include <QxtHttpsServerConnector>
  10. #include <QFile>
  11. class myservice : public QxtWebSlotService
  12. {
  13.     Q_OBJECT;
  14. public:
  15.     myservice(QxtAbstractWebSessionManager * sm, QObject * parent = 0 );
  16. public slots:
  17.     void index(QxtWebRequestEvent* event);
  18.  
  19. };

service.cpp:

  1. #include "service.h"
  2.  
  3.  
  4.  
  5. myservice::myservice(QxtAbstractWebSessionManager * sm, QObject * parent ): QxtWebSlotService(sm,parent)
  6. {
  7. }
  8.  
  9. void myservice::index(QxtWebRequestEvent* event)
  10. {
  11.  qDebug()<<"llego aca";
  12.  postEvent(new QxtWebPageEvent(event->sessionID, event->requestID, "<h1>It Works!</h1>"));
  13. }

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.

 
  ‹‹ problème d’installation Qwt      Qt Static and 3rd party static library ››

You must log in to post a reply. Not a member yet? Register here!