PDA

View Full Version : getting error Failure "SSL handshake failed"



Radhika
25th November 2015, 09:42
void MainWindow::on_pushButton_clicked()
{
QNetworkReply* reply;
Request_reply( reply);

}
int MainWindow:: Request_reply(QNetworkReply* reply) {

// create custom temporary event loop on stack
QEventLoop eventLoop;

// "quit()" the event-loop, when the network request "finished()"
QNetworkAccessManager mgr;
QObject::connect(&mgr, SIGNAL(finished(QNetworkReply*)), &eventLoop, SLOT(quit()));

// the HTTP request
//QNetworkRequest req( QUrl( QString("http://time.jsontest.com/") ) );
QNetworkRequest req( QUrl( QString("https://10.201.58.87:2342/kirk/1.0/") ) );
reply = mgr.get(req);
eventLoop.exec(); // blocks stack until "finished()" has been called

if (reply->error() == QNetworkReply::NoError) {

QString strReply = (QString)reply->readAll();

//parse json
qDebug() << "INFO:" << strReply;
QJsonDocument jsonResponse = QJsonDocument::fromJson(strReply.toUtf8());

QJsonObject jsonObj = jsonResponse.object();

qDebug() << "name:" << jsonObj["name"].toString();
qDebug() << "build_version:" << jsonObj["build_version"].toString();
QString str = jsonObj["name"].toString();
ui->label1->setText(str);

//delete reply;
}
else {
//failure
qDebug() << "Failure" <<reply->errorString();
delete reply;
}
return 0;
}

jefftee
25th November 2015, 21:26
Take a look at QNetworkReply::ignoreSslErrors. Most likely you have a certificate error unless the certificates used by 10.201.58.87 are verifiable, which most self-signed certificates are not.