2
votes

I am trying to make POST request to remote server. Here is my code:

void LoginWindow::on_login_pushButton_clicked()
{
    const QString url = ui->server_lineEdit->text ();
    const QString username = ui->username_lineEdit->text ();
    const QString password = ui->password_lineEdit->text ();
    QNetworkAccessManager mAccessManager;
    QNetworkRequest request(QUrl(url + "/api/auth/"));

    QUrlQuery urlQuery;
    urlQuery.addQueryItem ("username", username);
    urlQuery.addQueryItem ("password", password);

    QUrl params;
    params.setQuery (urlQuery);

    QNetworkReply* reply = mAccessManager.post (request, params.toEncoded ());

    connect (reply, &QNetworkReply::readyRead, [reply]() {
        qDebug()  << "Ready to read from reply";
    });
    connect (reply, &QNetworkReply::sslErrors, [this] (QList<QSslError> error) {
        qWarning () << "Ssl error: " << error;
    });

}

When I clicked the login button nothing happens, except a message in application output tab.

qt.network.ssl: QSslSocket: cannot resolve SSLv2_client_method
qt.network.ssl: QSslSocket: cannot resolve SSLv2_server_method

I checked the remote server log, there was no request from qt client.

I am using ubuntu 16.04 and Qt 5.9 . I also followed this solution, still no luck

1
Do you have OpenSSL installed on your machine as in the solution link?Azeem
I also had that problem with openssl in windows too. you should install openssl in ubuntu. sudo apt-get install libssl-devsaeed
@saeed Azeem both packages are already installedpyprism

1 Answers

0
votes

sslv2 is completely disabled in newer distributions , install libssl-0.98 from launchpad by dpkg.

Open a terminal, go to the extracted folder and run:

sudo dpkg -i file.deb

sudo apt-get install -f

You can use QSsl::SecureProtocols to enable the SSL versions which are considered secure as of the Qt release.