Skip to content

Commit

Permalink
compare authors using Thumbprint
Browse files Browse the repository at this point in the history
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130929
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
(cherry picked from commit 6544220)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130866
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
(cherry picked from commit a7aaa78)

Change-Id: I338f58eb07cbf0a3d13a7dafdaddac09252a8546
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131368
Tested-by: Michael Stahl <michael.stahl@allotropia.de>
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
  • Loading branch information
Caolán McNamara authored and mistmist committed Mar 11, 2022
1 parent 66a15ff commit 0ce93b3
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions xmlsecurity/source/component/documentdigitalsignatures.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -636,9 +636,18 @@ sal_Bool DocumentDigitalSignatures::isAuthorTrusted(
Sequence< SvtSecurityOptions::Certificate > aTrustedAuthors = SvtSecurityOptions().GetTrustedAuthors();

return std::any_of(aTrustedAuthors.begin(), aTrustedAuthors.end(),
[&xAuthor, &sSerialNum](const SvtSecurityOptions::Certificate& rAuthor) {
return xmlsecurity::EqualDistinguishedNames(rAuthor[0], xAuthor->getIssuerName(), xmlsecurity::NOCOMPAT)
&& ( rAuthor[1] == sSerialNum );
[this, &xAuthor, &sSerialNum](const SvtSecurityOptions::Certificate& rAuthor) {
if (!xmlsecurity::EqualDistinguishedNames(rAuthor[0], xAuthor->getIssuerName(), xmlsecurity::NOCOMPAT))
return false;
if (rAuthor[1] != sSerialNum)
return false;

DocumentSignatureManager aSignatureManager(mxCtx, {});
if (!aSignatureManager.init())
return false;
uno::Reference<css::security::XCertificate> xCert =
aSignatureManager.getSecurityEnvironment()->createCertificateFromAscii(rAuthor[2]);
return xCert->getSHA1Thumbprint() == xAuthor->getSHA1Thumbprint();
});
}

Expand Down

0 comments on commit 0ce93b3

Please sign in to comment.