PDA

View Full Version : Ssl problems



Unplugged
2nd October 2007, 18:08
Hi!
I am trying to write program which shows amount of money on my ISP account. The idea is to pass a POST request to index.php and receive generated html page, but there is ssl installed and that is a problem. When I am trying to pass my login and password to index.php through my program, as an output i receive main page as if login or password is incorrect.
#ifndef STAT_H
#define STAT_H
#include <QtNetwork>
#include <QtGui>

#include "ui_stat.h"

class Stat : public QDialog, public Ui::dialog
{
Q_OBJECT
public:
Stat (const QString &host)
{
setupUi ( this );
connect (&http, SIGNAL( requestFinished(int,bool)),this,SLOT(end()));
connect ( statButton, SIGNAL ( clicked ( ) ), this, SLOT ( send ( ) ) );
http.setHost ( host, QHttp::ConnectionModeHttps );
}


void sendData (const QString &input1, const QString &input2 )
{
data.append ( "FindUserName=");
data.append (input1);
data.append ( "&FindUserPass=");
data.append ( input2 );
outFile .setFileName ( "out.html" );
outFile.open (QIODevice:: WriteOnly | QIODevice::Truncate);
QSslSocket *socket = new QSslSocket;
socket->connectToHostEncrypted ( "stat.ultranet.ru", 443 );
if ( socket->waitForEncrypted ( 5000) )
{
http.setSocket ( socket );
QHttpRequestHeader header ( "POST", "/index.php" );
header.setValue ( "Content-Type", "application/x-www-form-urlencoded" );
header.setValue ( "Host", "stat.ultranet.ru" );
http.request ( header, data, &outFile );
}
}

public slots:
void end( )
{
outFile.close ( );
emit done();
}

void send ( )
{
sendData ( loginLineEdit ->text( ), passwLineEdit ->text( ) ) ;
}



signals:
void done( );
private:
QFile outFile;
QHttp http;
QByteArray data;
};
#endif

Unplugged
3rd October 2007, 21:35
Problem solved :D

jacek
3rd October 2007, 21:49
What was the problem?

Unplugged
4th October 2007, 07:02
I was just sending wrong string is POST request. The right one is "action=login&FindUserName=mylogin&FindUserPass=mypass" instead of "FindUserName=mylogin&FindUserPass=mypass". I figured this out when intercepted POST request from IE.