Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
QNetworkAccessManager and HTTPS
antonio last edited by
I'm a newbie at SSL and https... I need to send files by Https... I've searched about how to use of QNetworkAccessManager, QNetworkRequest, QHttpMultipart, QnetworkReply and QSslSocket for working together without any success. Can you give me some guide about it?
Code_ReaQtor last edited by
Try to install an SSL library, "OpenSSL":http://www.openssl.org/
Are you using the source version of Qt? Mening you compile your Qt yourself?
If so you need to download precompiled OpenSSL libraries or compile them yourself. And reconfigure and recompile Qt.
AFAIK the prebuild Qt releases should already have OpenSSL integrated.
Please tell us what exactly didn't work out for you. Also there a many resources on the web how to use ssl in your Qt application.
antonio last edited by
Hello this is part of my code,
qDebug() <<certFile.fileName() << " not opened";
QByteArray arrayCert = certFile.readAll();
QSslCertificate cert(arrayCert, QSsl::Pem);
qDebug() << "null: " << cert.isNull() << " valid: " << cert.isValid() ;
QSslSocket *sslSocket = new QSslSocket(this);
QSslConfiguration config = sslSocket->sslConfiguration();
After that, I added some headers and a file.... then
reply = manager->post(request, multiPart);
after that I get this errors:
err: "The issuer certificate of a locally looked up certificate could not be found"
err: "The root CA certificate is not trusted for this purpose"
err: "No certificates could be verified"
I supouse that my ssl config is bad.
updatenode last edited by
are you sure your certificate is encoding using Qt::Pem format? OR is it QSsl::Der?
We had same issues and the reason was that we have extracted the certificate as DER encoded and passed Qt::Pem.
Other than that, make sure you have all SSL dependencies installed and check your code again. Usually it's not need to define a QSslSocket if your are using the QNetworkManager.
We are setting the root CA from geotrust just in case its not available:
QSslConfiguration defaultSSLConfig = QSslConfiguration::defaultConfiguration();
QList<QSslCertificate> certificates = defaultSSLConfig.caCertificates();
QSslCertificate certificate(&cert, QSsl::Der);
afterwards you can access your server with QNetworkManager and QWebKit.
Hope that helps