From 89972b872782698c48d9c919c5766240f0a81d41 Mon Sep 17 00:00:00 2001 From: Lauris Kaplinski Date: Thu, 21 May 2026 13:56:47 +0300 Subject: [PATCH 1/5] Return configuration error if keyserver is not known --- client/CDocSupport.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/client/CDocSupport.cpp b/client/CDocSupport.cpp index 47a4419d1..e49a4db0f 100644 --- a/client/CDocSupport.cpp +++ b/client/CDocSupport.cpp @@ -188,26 +188,33 @@ checkConnection() std::string DDConfiguration::getValue(std::string_view domain, std::string_view param) const { - std::string def = Settings::CDOC2_DEFAULT_KEYSERVER; if (param == libcdoc::Configuration::KEYSERVER_SEND_URL) { #ifdef CONFIG_URL QJsonObject list = Application::confValue(QLatin1String("CDOC2-CONF")).toObject(); + if (list.isEmpty()) return {}; QJsonObject data = list.value(QLatin1String(domain.data(), domain.size())).toObject(); - QString url = data.value(QLatin1String("POST")).toString(Settings::CDOC2_POST); + if (data.isEmpty()) return {}; + QString url = data.value(QLatin1String("POST")).toString(); return url.toStdString(); #else - QString url = Settings::CDOC2_POST; - return url.toStdString(); + if (domain == Settings::CDOC2_DEFAULT_KEYSERVER) { + QString url = Settings::CDOC2_POST; + return url.toStdString(); + } #endif } else if (param == libcdoc::Configuration::KEYSERVER_FETCH_URL) { #ifdef CONFIG_URL QJsonObject list = Application::confValue(QLatin1String("CDOC2-CONF")).toObject(); + if (list.isEmpty()) return {}; QJsonObject data = list.value(QLatin1String(domain.data(), domain.size())).toObject(); - QString url = data.value(QLatin1String("FETCH")).toString(Settings::CDOC2_GET); + if (data.isEmpty()) return {}; + QString url = data.value(QLatin1String("FETCH")).toString(); return url.toStdString(); #else - QString url = Settings::CDOC2_GET; - return url.toStdString(); + if (domain == Settings::CDOC2_DEFAULT_KEYSERVER) { + QString url = Settings::CDOC2_GET; + return url.toStdString(); + } #endif } return {}; From c5d629e692f8944cf3228bcd2635cfc48195d027 Mon Sep 17 00:00:00 2001 From: lauris71 Date: Wed, 23 Sep 2026 14:15:12 +0300 Subject: [PATCH 2/5] FetchKey uses backend error code if not PinOK --- client/CDocSupport.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/client/CDocSupport.cpp b/client/CDocSupport.cpp index 7b9c969c2..78386e492 100644 --- a/client/CDocSupport.cpp +++ b/client/CDocSupport.cpp @@ -344,6 +344,13 @@ DDNetworkBackend::fetchKey(std::vector &result, const std::string &url, e.exec(); if(reply->error() != QNetworkReply::NoError && reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() != 201) { + if (backend.get()->status != QCryptoBackend::PinOK) { + // The actual error was in QCryptoBackend + libcdoc::result_t result = getDecryptStatus(backend.get()->status); + last_error = getLastErrorStr(result); + return result; + } + // Probably network problem last_error = reply->errorString().toStdString(); return BACKEND_ERROR; } From d04532b242c5b3c173ab8f559c5ee4815e771bae Mon Sep 17 00:00:00 2001 From: Lauris Kaplinski Date: Wed, 23 Sep 2026 14:37:35 +0300 Subject: [PATCH 3/5] Updated generic decryption error description --- client/CryptoDoc.cpp | 2 +- client/translations/en.ts | 16 ++++++++++++++-- client/translations/et.ts | 16 ++++++++++++++-- 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/client/CryptoDoc.cpp b/client/CryptoDoc.cpp index a285cbaa9..13e091431 100644 --- a/client/CryptoDoc.cpp +++ b/client/CryptoDoc.cpp @@ -364,7 +364,7 @@ bool CryptoDoc::decrypt(const libcdoc::Lock *lock, const QByteArray& secret) str = QCryptoBackend::errorString(QCryptoBackend::Status::InProgress); break; default: - str = tr("Please check your internet connection and network settings."); + str = tr("General decryption error. Neither the card reader not network layer did not give more information. Please check your internet connection, network settings and card reader. On some readers it may also indicate the wrong pin code or locked card."); break; } WarningDialog::create() diff --git a/client/translations/en.ts b/client/translations/en.ts index 2a74ebd60..b1020da79 100644 --- a/client/translations/en.ts +++ b/client/translations/en.ts @@ -499,11 +499,11 @@ You are about to delete the last file in the container - You are about to delete the last file in the container + You are about to delete the last file in the container It is removed along with the container. - It is removed along with the container. + It is removed along with the container. In order to view Validity Confirmation Sheet there has to be at least one printer installed! @@ -636,6 +636,10 @@ Cannot read file. Cannot read file. + + General decryption error. Neither the card reader not network layer did not give more information. Please check your internet connection, network settings and card reader. On some readers it may also indicate the wrong pin code or locked card. + + Diagnostics @@ -3083,6 +3087,14 @@ Additional licenses and components Remove Remove + + You are about to delete the last file in the container + You are about to delete the last file in the container + + + It is removed along with the container. + It is removed along with the container. + WarningItem diff --git a/client/translations/et.ts b/client/translations/et.ts index 24e461bfd..35c6e7e13 100644 --- a/client/translations/et.ts +++ b/client/translations/et.ts @@ -499,11 +499,11 @@ You are about to delete the last file in the container - Oled kustutamas viimast faili ümbrikus + Oled kustutamas viimast faili ümbrikus It is removed along with the container. - Koos sellega eemaldatakse ka ümbrik. + Koos sellega eemaldatakse ka ümbrik. In order to view Validity Confirmation Sheet there has to be at least one printer installed! @@ -636,6 +636,10 @@ Cannot read file. Faili ei saa lugeda. + + General decryption error. Neither the card reader not network layer did not give more information. Please check your internet connection, network settings and card reader. On some readers it may also indicate the wrong pin code or locked card. + Täpsustamata dekrüpteerimise viga. Ei kaardilugeja ega võrguühendus ei andnud täpsemat informatsiooni. Kontrollige internetiühendust, võrgu sätteid ja kaardilugejat. Mõne lugeja korral võib põhjuseks olla ka vale pin või lukustatud kaart. + Diagnostics @@ -3083,6 +3087,14 @@ Täiendavad litsentsid ja komponendid Remove Eemalda + + You are about to delete the last file in the container + Oled kustutamas viimast faili ümbrikus + + + It is removed along with the container. + Koos sellega eemaldatakse ka ümbrik. + WarningItem From 11f5c324e7217d0137aac7b5f84540e9ebf19062 Mon Sep 17 00:00:00 2001 From: Lauris Kaplinski Date: Wed, 23 Sep 2026 15:34:19 +0300 Subject: [PATCH 4/5] A bit better error reporting Signed-off-by: Lauris Kaplinski --- client/CryptoDoc.cpp | 3 +++ client/QCryptoBackend.cpp | 6 +++--- client/translations/en.ts | 18 +++++++++++++----- client/translations/et.ts | 14 +++++++++++--- 4 files changed, 30 insertions(+), 11 deletions(-) diff --git a/client/CryptoDoc.cpp b/client/CryptoDoc.cpp index 13e091431..0b2620f25 100644 --- a/client/CryptoDoc.cpp +++ b/client/CryptoDoc.cpp @@ -363,6 +363,9 @@ bool CryptoDoc::decrypt(const libcdoc::Lock *lock, const QByteArray& secret) case DDCryptoBackend::IN_PROGRESS: str = QCryptoBackend::errorString(QCryptoBackend::Status::InProgress); break; + case DDCryptoBackend::BACKEND_ERROR: + str = QCryptoBackend::errorString(QCryptoBackend::Status::GeneralError); + break; default: str = tr("General decryption error. Neither the card reader not network layer did not give more information. Please check your internet connection, network settings and card reader. On some readers it may also indicate the wrong pin code or locked card."); break; diff --git a/client/QCryptoBackend.cpp b/client/QCryptoBackend.cpp index 4c7640fe8..1210b4564 100644 --- a/client/QCryptoBackend.cpp +++ b/client/QCryptoBackend.cpp @@ -91,9 +91,9 @@ QString QCryptoBackend::errorString(Status error) case PinCanceled: return QCoreApplication::translate("QCryptoBackend", "PIN entry canceled"); case PinLocked: return QCoreApplication::translate("QCryptoBackend", "PIN locked"); case PinIncorrect: return QCoreApplication::translate("QCryptoBackend", "PIN incorrect"); - case InProgress: return QCoreApplication::translate("QCryptoBackend", "Signing/decrypting is already in progress another window."); - case GeneralError: return QCoreApplication::translate("QCryptoBackend", "PKCS11 general error"); - case DeviceError: return QCoreApplication::translate("QCryptoBackend", "PKCS11 device error"); + case InProgress: return QCoreApplication::translate("QCryptoBackend", "Signing/decrypting is already in progress in another window."); + case GeneralError: return QCoreApplication::translate("QCryptoBackend", "Error in smart card driver, reader or the card. On some readers it may indicate the wrong pin code or locked card."); + case DeviceError: return QCoreApplication::translate("QCryptoBackend", "Error in smart card driver, reader or the card. On some readers it may indicate the wrong pin code or locked card."); default: return QCoreApplication::translate("QCryptoBackend", "Unknown error"); } } diff --git a/client/translations/en.ts b/client/translations/en.ts index b1020da79..1797745ce 100644 --- a/client/translations/en.ts +++ b/client/translations/en.ts @@ -610,7 +610,7 @@ Key transfer server is not configured - + Key transfer server is not configured Failed to remove key @@ -638,7 +638,7 @@ General decryption error. Neither the card reader not network layer did not give more information. Please check your internet connection, network settings and card reader. On some readers it may also indicate the wrong pin code or locked card. - + General decryption error. Neither the card reader not network layer did not give more information. Please check your internet connection, network settings and card reader. On some readers it may also indicate the wrong pin code or locked card. @@ -2170,15 +2170,15 @@ ID-Card Signing/decrypting is already in progress another window. - Signing/decrypting is already in progress another window. + Signing/decrypting is already in progress another window. PKCS11 general error - PKCS11 general error + PKCS11 general error PKCS11 device error - PKCS11 device error + PKCS11 device error Unknown error @@ -2192,6 +2192,14 @@ ID-Card PIN entry canceled PIN entry canceled + + Signing/decrypting is already in progress in another window. + Signing/decrypting is already in progress in another window. + + + Error in smart card driver, reader or the card. On some readers it may indicate the wrong pin code or locked card. + Error in smart card driver, reader or the card. On some readers it may indicate the wrong pin code or locked card. + QFileDialog diff --git a/client/translations/et.ts b/client/translations/et.ts index 35c6e7e13..339776cca 100644 --- a/client/translations/et.ts +++ b/client/translations/et.ts @@ -2170,15 +2170,15 @@ ID-kaardiga Signing/decrypting is already in progress another window. - Allkirjastamine/dekrüpteerimine on juba käimas teises aknas. + Allkirjastamine/dekrüpteerimine on juba käimas teises aknas. PKCS11 general error - PKCS11 üldine viga + PKCS11 üldine viga PKCS11 device error - PKCS11 seadme viga + PKCS11 seadme viga Unknown error @@ -2192,6 +2192,14 @@ ID-kaardiga PIN entry canceled PIN sisestus katkestatus + + Signing/decrypting is already in progress in another window. + Allkirjastamine/dekrüpteerimine juba toimub teises aknas. + + + Error in smart card driver, reader or the card. On some readers it may indicate the wrong pin code or locked card. + Viga kiipkaardi draiveris, lugejas või kaardis. Osade draiverite korral võib see tähendada ka lihtsalt vale PIN-i või lukus kaarti. + QFileDialog From a4375785abcea27be80d5d88c94eea290dbd028c Mon Sep 17 00:00:00 2001 From: Lauris Kaplinski Date: Wed, 23 Sep 2026 15:37:09 +0300 Subject: [PATCH 5/5] Fix CodeQL warning Signed-off-by: Lauris Kaplinski --- client/CDocSupport.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/client/CDocSupport.cpp b/client/CDocSupport.cpp index 78386e492..f85e806e7 100644 --- a/client/CDocSupport.cpp +++ b/client/CDocSupport.cpp @@ -346,9 +346,9 @@ DDNetworkBackend::fetchKey(std::vector &result, const std::string &url, if(reply->error() != QNetworkReply::NoError && reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() != 201) { if (backend.get()->status != QCryptoBackend::PinOK) { // The actual error was in QCryptoBackend - libcdoc::result_t result = getDecryptStatus(backend.get()->status); - last_error = getLastErrorStr(result); - return result; + libcdoc::result_t lresult = getDecryptStatus(backend.get()->status); + last_error = getLastErrorStr(lresult); + return lresult; } // Probably network problem last_error = reply->errorString().toStdString();