Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate CAdES signature in SiVa service #1216

Merged
merged 1 commit into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
container: ${{ matrix.container }}
strategy:
matrix:
container: ['ubuntu:20.04', 'ubuntu:22.04', 'ubuntu:23.04']
container: ['ubuntu:20.04', 'ubuntu:22.04', 'ubuntu:23.04', 'ubuntu:23.10']
env:
DEBIAN_FRONTEND: noninteractive
DEBFULLNAME: github-actions
Expand Down Expand Up @@ -110,7 +110,9 @@ jobs:
MAKEFLAGS: -j3
steps:
- name: Install Deps
run: dnf install -y git gcc-c++ cmake rpm-build gettext openssl-devel openldap-devel pcsc-lite-devel qt6-qtsvg-devel qt6-qttools-devel qt6-qt5compat-devel flatbuffers-devel flatbuffers-compiler zlib-devel
run: |
dnf install -y --setopt=install_weak_deps=False \
git gcc-c++ cmake rpm-build gettext openssl-devel openldap-devel pcsc-lite-devel qt6-qtsvg-devel qt6-qttools-devel qt6-qt5compat-devel flatbuffers-devel flatbuffers-compiler zlib-devel
- name: Checkout
uses: actions/checkout@v4
with:
Expand Down
9 changes: 8 additions & 1 deletion client/DigiDoc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,13 @@ bool DigiDoc::isAsicS() const
});
}

bool DigiDoc::isCades() const
{
return std::any_of(m_signatures.cbegin(), m_signatures.cend(), [](const DigiDocSignature &s) {
return s.profile().contains(QLatin1String("CADES"), Qt::CaseInsensitive);
});
}

bool DigiDoc::isPDF() const
{
return b && b->mediaType() == "application/pdf";
Expand All @@ -461,7 +468,7 @@ bool DigiDoc::isModified() const { return modified; }

bool DigiDoc::isSupported() const
{
return b && b->mediaType() == "application/vnd.etsi.asic-e+zip";
return b && b->mediaType() == "application/vnd.etsi.asic-e+zip" && !isCades();
}

QString DigiDoc::mediaType() const
Expand Down
1 change: 1 addition & 0 deletions client/DigiDoc.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ class DigiDoc: public QObject
DocumentModel *documentModel() const;
QString fileName() const;
bool isAsicS() const;
bool isCades() const;
bool isPDF() const;
bool isModified() const;
bool isSupported() const;
Expand Down
1 change: 1 addition & 0 deletions client/common_enums.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ enum WarningType {
UnknownSignatureWarning,
UnknownTimestampWarning,
UnsupportedAsicSWarning,
UnsupportedAsicCadesWarning,
UnsupportedDDocWarning,
EmptyFileWarning,
};
Expand Down
4 changes: 4 additions & 0 deletions client/translations/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3288,6 +3288,10 @@ Additional licenses and components</translation>
<source>This ASiC-S container contains XAdES signature. You are not allowed to add or remove signatures to this container.</source>
<translation>This ASiC-S container contains XAdES signature. You are not allowed to add or remove signatures to this container.</translation>
</message>
<message>
<source>This container contains CAdES signature. You are not allowed to add or remove signatures to this container.</source>
<translation>This container contains CAdES signature. You are not allowed to add or remove signatures to this container.</translation>
</message>
</context>
<context>
<name>WarningRibbon</name>
Expand Down
6 changes: 5 additions & 1 deletion client/translations/et.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3286,7 +3286,11 @@ Täiendavad litsentsid ja komponendid</translation>
</message>
<message>
<source>This ASiC-S container contains XAdES signature. You are not allowed to add or remove signatures to this container.</source>
<translation>Tegemist on XAdES allkirja sisalduva ASiC-S ümbrikuga. Sellele ümbrikule ei saa allkirja lisada ega eemaldada.</translation>
<translation>Tegemist on XAdES allkirja sisaldava ASiC-S ümbrikuga. Sellele ümbrikule ei saa allkirja lisada ega eemaldada.</translation>
</message>
<message>
<source>This container contains CAdES signature. You are not allowed to add or remove signatures to this container.</source>
<translation>Tegemist on CAdES allkirja sisaldava ümbrikuga. Sellele ümbrikule ei saa allkirja lisada ega eemaldada.</translation>
</message>
</context>
<context>
Expand Down
4 changes: 4 additions & 0 deletions client/translations/ru.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3293,6 +3293,10 @@ Additional licenses and components</source>
<source>This ASiC-S container contains XAdES signature. You are not allowed to add or remove signatures to this container.</source>
<translation>Речь идет о конверте ASiC-S, содержащемся в подписи XAdES. К данному контейнеру нельзя добавить или удалить из него подпись.</translation>
</message>
<message>
<source>This container contains CAdES signature. You are not allowed to add or remove signatures to this container.</source>
<translation>Этот контейнер содержит подпись CAdES. К данному контейнеру нельзя добавить или удалить из него подпись.</translation>
</message>
</context>
<context>
<name>WarningRibbon</name>
Expand Down
2 changes: 2 additions & 0 deletions client/widgets/ContainerPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,8 @@ void ContainerPage::transition(DigiDoc* container)
emit warning(UnsupportedDDocWarning);
if(container->isAsicS())
emit warning(UnsupportedAsicSWarning);
if(container->isCades())
emit warning(UnsupportedAsicCadesWarning);

hasEmptyFile = false;
for (auto i = 0; i < container->documentModel()->rowCount(); i++)
Expand Down
10 changes: 9 additions & 1 deletion client/widgets/WarningItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,16 @@ void WarningItem::lookupWarning()
warnText.details = tr("More information");
warnText.page = ria::qdigidoc4::SignDetails;
break;
case ria::qdigidoc4::UnsupportedAsicCadesWarning:
warnText.text = tr("This container contains CAdES signature. "
"You are not allowed to add or remove signatures to this container.");
warnText.url = tr("https://www.id.ee/en/article/digidoc-container-format-life-cycle-2/");
warnText.details = tr("More information");
warnText.page = ria::qdigidoc4::SignDetails;
break;
case ria::qdigidoc4::UnsupportedDDocWarning:
warnText.text = tr("The current file is a DigiDoc container that is not supported officially any longer. You are not allowed to add or remove signatures to this container.");
warnText.text = tr("The current file is a DigiDoc container that is not supported officially any longer. "
"You are not allowed to add or remove signatures to this container.");
warnText.url = tr("https://www.id.ee/en/article/digidoc-container-format-life-cycle-2/");
warnText.details = tr("More information");
warnText.page = ria::qdigidoc4::SignDetails;
Expand Down