subhashree satpathy
4th April 2018, 05:49
We updated TLS 1.0 to TLS 1.1 . But our application ( QT 4.7.4 ) does not support TLS 1.1 .Currently we are using QNetworkManager to communicate with server and https is not atall hitting the server.so please suggest us how we can resolve this issue ?In Qt 5.x same code working perfectly and getting the data also.here is a sample code
void Downloader::doDownload()
{
manager = new QNetworkAccessManager(this);
connect(manager, SIGNAL(finished(QNetworkReply*)),
this, SLOT(replyFinished(QNetworkReply*)));
manager->get(QNetworkRequest(QUrl("https://www.yahoo.com")));
}
void Downloader::replyFinished (QNetworkReply *reply)
{
if(reply->error())
{
qDebug() << "ERROR!";
qDebug() << reply->errorString();
}
else
{
qDebug() << reply->header(QNetworkRequest::ContentTypeHeader).toStrin g();
qDebug() << reply->header(QNetworkRequest::LastModifiedHeader).toDate Time().toString();
qDebug() << reply->header(QNetworkRequest::ContentLengthHeader).toULo ngLong();
qDebug() << reply->attribute(QNetworkRequest::HttpStatusCodeAttribute ).toInt();
qDebug() << reply->attribute(QNetworkRequest::HttpReasonPhraseAttribu te).toString();
QFile *file = new QFile("/root/NETWORK/tlsnet/ntwrkmangr/downloaded.txt");
if(file->open(QFile::Append))
{
file->write(reply->readAll());
file->flush();
file->close();
}
delete file;
}
reply->deleteLater();
}
void Downloader::doDownload()
{
manager = new QNetworkAccessManager(this);
connect(manager, SIGNAL(finished(QNetworkReply*)),
this, SLOT(replyFinished(QNetworkReply*)));
manager->get(QNetworkRequest(QUrl("https://www.yahoo.com")));
}
void Downloader::replyFinished (QNetworkReply *reply)
{
if(reply->error())
{
qDebug() << "ERROR!";
qDebug() << reply->errorString();
}
else
{
qDebug() << reply->header(QNetworkRequest::ContentTypeHeader).toStrin g();
qDebug() << reply->header(QNetworkRequest::LastModifiedHeader).toDate Time().toString();
qDebug() << reply->header(QNetworkRequest::ContentLengthHeader).toULo ngLong();
qDebug() << reply->attribute(QNetworkRequest::HttpStatusCodeAttribute ).toInt();
qDebug() << reply->attribute(QNetworkRequest::HttpReasonPhraseAttribu te).toString();
QFile *file = new QFile("/root/NETWORK/tlsnet/ntwrkmangr/downloaded.txt");
if(file->open(QFile::Append))
{
file->write(reply->readAll());
file->flush();
file->close();
}
delete file;
}
reply->deleteLater();
}