Thanks for your replies, anda_skoa. I assume that by enum you mean the number of errors? In which case it'd agree, it's 2. Forcing SSLv3 or SSLv2 has identical effect to not forcing protocol: Blank reply. Forcing TLS gives the strange SSL errors. Can confirm again that http:// returns index.html of a page just fine, including this one's!
Here's the code I'm using:
mw.h
#ifndef MW_H
#define MW_H
#include <QtGui/QMainWindow>
#include <QNetworkAccessManager>
#include <QNetworkRequest>
#include <QNetworkReply>
#include <QSslError>
#include <QSslConfiguration>
#include <QUrl>
#include <fstream>
namespace Ui
{
class mw;
}
{
Q_OBJECT
public:
~mw();
public slots:
void rfinish(QNetworkReply *);
void refresh();
void errors(QNetworkReply *,QList<QSslError>);
private:
Ui::mw *ui;
QNetworkAccessManager *nwam;
};
#endif // MW_H
#ifndef MW_H
#define MW_H
#include <QtGui/QMainWindow>
#include <QNetworkAccessManager>
#include <QNetworkRequest>
#include <QNetworkReply>
#include <QSslError>
#include <QSslConfiguration>
#include <QUrl>
#include <fstream>
namespace Ui
{
class mw;
}
class mw : public QMainWindow
{
Q_OBJECT
public:
mw(QWidget *parent = 0);
~mw();
public slots:
void rfinish(QNetworkReply *);
void refresh();
void errors(QNetworkReply *,QList<QSslError>);
private:
Ui::mw *ui;
QNetworkAccessManager *nwam;
};
#endif // MW_H
To copy to clipboard, switch view to plain text mode
mw.cpp
#include "mw.h"
#include "ui_mw.h"
using namespace std;
{
ui->setupUi(this);
nwam=new QNetworkAccessManager();
connect(ui->pushButton,SIGNAL(clicked()),this,SLOT(refresh()));
connect(nwam,SIGNAL(finished(QNetworkReply*)),this,SLOT(rfinish(QNetworkReply*)));
connect(nwam,SIGNAL(sslErrors(QNetworkReply*,QList<QSslError>)),this,SLOT(errors(QNetworkReply*,QList<QSslError>)));
}
void mw::refresh(){
QUrl url
("https://www.btc-e.com/api/3/ticker/btc_usd");
QNetworkRequest request;
request.setUrl(url);
QSslConfiguration config = QSslConfiguration::defaultConfiguration();
// config.setProtocol(QSsl::TlsV1);
request.setSslConfiguration(config);
nwam->get(request);
ui->statusBar->showMessage("Updating...",0);
}
void mw::rfinish(QNetworkReply *r){
ofstream file;
file.open("debug.txt");
file << reply.toStdString().c_str() << endl;
file.close();
ui->statusBar->showMessage("reply received",3000);
}
void mw::errors(QNetworkReply *r,QList<QSslError> errList){
ofstream file;
file.open("debugErr.txt");
file << errList.size() << endl;
for (int i=0;i<errList.size();i++) file << errList[i].errorString().toStdString().c_str() << endl;
file.close();
ui->statusBar->showMessage("SSL errors",3000);
}
mw::~mw()
{
delete ui;
}
#include "mw.h"
#include "ui_mw.h"
using namespace std;
mw::mw(QWidget *parent)
: QMainWindow(parent), ui(new Ui::mw)
{
ui->setupUi(this);
nwam=new QNetworkAccessManager();
connect(ui->pushButton,SIGNAL(clicked()),this,SLOT(refresh()));
connect(nwam,SIGNAL(finished(QNetworkReply*)),this,SLOT(rfinish(QNetworkReply*)));
connect(nwam,SIGNAL(sslErrors(QNetworkReply*,QList<QSslError>)),this,SLOT(errors(QNetworkReply*,QList<QSslError>)));
}
void mw::refresh(){
QUrl url("https://www.btc-e.com/api/3/ticker/btc_usd");
QNetworkRequest request;
request.setUrl(url);
QSslConfiguration config = QSslConfiguration::defaultConfiguration();
// config.setProtocol(QSsl::TlsV1);
request.setSslConfiguration(config);
nwam->get(request);
ui->statusBar->showMessage("Updating...",0);
}
void mw::rfinish(QNetworkReply *r){
QString reply=QString::fromUtf8(r->readAll());
ofstream file;
file.open("debug.txt");
file << reply.toStdString().c_str() << endl;
file.close();
ui->statusBar->showMessage("reply received",3000);
}
void mw::errors(QNetworkReply *r,QList<QSslError> errList){
ofstream file;
file.open("debugErr.txt");
file << errList.size() << endl;
for (int i=0;i<errList.size();i++) file << errList[i].errorString().toStdString().c_str() << endl;
file.close();
ui->statusBar->showMessage("SSL errors",3000);
}
mw::~mw()
{
delete ui;
}
To copy to clipboard, switch view to plain text mode
main.cpp (default
#include <QtGui/QApplication>
#include "mw.h"
int main(int argc, char *argv[])
{
mw w;
w.show();
return a.exec();
}
.pro file has QT += network added
.ui file has a push button called pushButton.
#include <QtGui/QApplication>
#include "mw.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
mw w;
w.show();
return a.exec();
}
.pro file has QT += network added
.ui file has a push button called pushButton.
To copy to clipboard, switch view to plain text mode
Any ideas?
Thanks in advance.
Bookmarks