Skip to content
Snippets Groups Projects
Verified Commit 98df84dd authored by Tobias Triffterer's avatar Tobias Triffterer :house_with_garden:
Browse files

Configure Encryption on the Client

The code necessary to encrypt the connection and verify the server using
the list of CA certificates from libfp311online.
parent e2534749
No related branches found
No related tags found
No related merge requests found
Pipeline #3162 passed with stage
in 42 seconds
......@@ -30,8 +30,10 @@
#include <QTimer>
#include <QPalette>
#include <QPixmap>
#include <QSslConfiguration>
#include <QUrl>
#include "cacertificates.h"
#include "clientgui.h"
#include "command.h"
#include "legalstuff.h"
......@@ -63,8 +65,13 @@ void LoginGui::doLogin()
_ui.txtStartPin->setEnabled(false);
_ui.cmdLogin->setEnabled(false);
logInfo(QStringLiteral("Opening web socket to address ws://") + _ui.txtUrl->text());
logInfo(QStringLiteral("Opening web socket to address wss://") + _ui.txtUrl->text());
_socket.reset(new QWebSocket);
QSslConfiguration sslconfig = _socket->sslConfiguration();
sslconfig.setCaCertificates(CaCertificates::getCaCertificatesFromResource());
_socket->setSslConfiguration(sslconfig);
connect(_socket.get(), QOverload<QAbstractSocket::SocketError>::of(&QWebSocket::error), this, &LoginGui::socketError);
connect(_socket.get(), &QWebSocket::connected, this, &LoginGui::sendAuthenticateMessage);
connect(_socket.get(), &QWebSocket::textFrameReceived, this, &LoginGui::receivedMessageFromServer);
......@@ -73,7 +80,7 @@ void LoginGui::doLogin()
_ui.pbStatus->setMinimum(0); // Activate busy indicator
_ui.pbStatus->setMaximum(0);
_socket->open(QUrl(QStringLiteral("ws://") + _ui.txtUrl->text()));
_socket->open(QUrl(QStringLiteral("wss://") + _ui.txtUrl->text()));
}
void LoginGui::sendAuthenticateMessage()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment