There was some problem of the next kind. There is an application that performs post and get requests, everything functions adequately, but only with http, if the call goes through https, then Qt throws out the error qt.network.ssl: QSslSocket :: connectToHostEncrypted: TLS initialization failed. After googling problems, I learned that the SSL libraries might be missing, hence the question, where can I get this business and how to connect it to the project? I will be grateful to any tips, just in case I attach my code
mainwindow.cpp
#include "mainwindow.h" #include "ui_mainwindow.h" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); } MainWindow::~MainWindow() { delete ui; } void MainWindow::on_pushButton_clicked() { QString A, B, C, X, Z; QByteArray data= "{ \"Authorization\":\"Bearer AQAAAAAGX9TiAATuwa8z\" }"; A=ui->lineEdit->text(); //широта B=ui->lineEdit_2->text(); //долгота C=ui->lineEdit_3->text(); // масштаб X= "https://static-maps.yandex.ru/1.x/?ll="+B+","+A+"&z="+C+"&size=600,450&l=map"; //сначала долгота ui->preview->load(QUrl(X)); ui->preview->show(); manager = new QNetworkAccessManager(); connect(manager, &QNetworkAccessManager::finished, this, &MainWindow::onResult); QNetworkRequest request(QUrl("https://mdb.api.cloud.yandex.net/managed-postgresql/v1/clusters/c9qmjpt4v23oohbuj1vu/databases/db1")); // manager->get(QNetworkRequest(QUrl("http://www.evileg.ru/it_example.json"))); manager->get(request); // manager->post(request, data); } void MainWindow::onResult(QNetworkReply *reply) { if(reply->error() == QNetworkReply::NoError){ QByteArray json_data = reply->readAll(); ui->textEdit->setPlainText(json_data) } else { qDebug() << "error: " << reply->error(); } reply->deleteLater(); }
mainwindow.h
#ifndef MAINWINDOW_H #define MAINWINDOW_H #include <QMainWindow> #include <QtNetwork/QNetworkAccessManager> #include <QtNetwork/QNetworkRequest> #include <QtNetwork/QNetworkReply> #include <QJsonDocument> #include <QJsonObject> #include <QJsonArray> #include <QUrlQuery> #include <QUrl> namespace Ui { class MainWindow; } class MainWindow : public QMainWindow { Q_OBJECT public: explicit MainWindow(QWidget *parent = nullptr); ~MainWindow(); private slots: void on_pushButton_clicked(); void onResult(QNetworkReply *reply); private: Ui::MainWindow *ui; QNetworkAccessManager* manager; }; #endif // MAINWINDOW_H