diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2021-12-21 14:06:56 +0100 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2021-12-21 14:09:52 +0100 |
commit | 784ff5fdb703f1f7fa1a54cae1ffdb541eb8367b (patch) | |
tree | bf7c336a9b37d89221010d3908cb0c03c823cc86 /xmlsecurity | |
parent | 11eefc1efaa617cf75449b5f81e39faed1b3448a (diff) |
xmlsecurity: log the signature we read from the ZIP package
We can already see if a signature verification fails and what is the
content of the ZIP streams we hash.
Show what is the expected hash as well.
Change-Id: Ibc67b7de0e8d03e06da1b86b6e8a7b2b2e613882
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127229
Tested-by: Andras Timar <andras.timar@collabora.com>
Reviewed-by: Andras Timar <andras.timar@collabora.com>
Diffstat (limited to 'xmlsecurity')
-rw-r--r-- | xmlsecurity/source/helper/documentsignaturehelper.cxx | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/xmlsecurity/source/helper/documentsignaturehelper.cxx b/xmlsecurity/source/helper/documentsignaturehelper.cxx index 05c7b0beb205..e222ab70332d 100644 --- a/xmlsecurity/source/helper/documentsignaturehelper.cxx +++ b/xmlsecurity/source/helper/documentsignaturehelper.cxx @@ -28,6 +28,7 @@ #include <com/sun/star/embed/StorageFormats.hpp> #include <com/sun/star/embed/ElementModes.hpp> #include <com/sun/star/beans/StringPair.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/xml/sax/XDocumentHandler.hpp> #include <comphelper/documentconstants.hxx> @@ -355,6 +356,31 @@ SignatureStreamHelper DocumentSignatureHelper::OpenSignatureStream( else aSIGStreamName = DocumentSignatureHelper::GetPackageSignatureDefaultStreamName(); +#ifdef SAL_LOG_INFO + aHelper.xSignatureStream = aHelper.xSignatureStorage->openStreamElement( aSIGStreamName, nOpenMode ); + SAL_INFO("xmlsecurity", + "DocumentSignatureHelper::OpenSignatureStream: stream name is '" + << aSIGStreamName << "'"); + if (aHelper.xSignatureStream.is()) + { + uno::Reference<io::XInputStream> xInputStream(aHelper.xSignatureStream, uno::UNO_QUERY); + sal_Int64 nSize = 0; + uno::Reference<beans::XPropertySet> xPropertySet(xInputStream, uno::UNO_QUERY); + xPropertySet->getPropertyValue("Size") >>= nSize; + if (nSize >= 0 || nSize < SAL_MAX_INT32) + { + uno::Sequence<sal_Int8> aData; + xInputStream->readBytes(aData, nSize); + SAL_INFO("xmlsecurity", + "DocumentSignatureHelper::OpenSignatureStream: stream content is '" + << OString(reinterpret_cast<const char*>(aData.getArray()), + aData.getLength()) + << "'"); + } + } + aHelper.xSignatureStream.clear(); +#endif + aHelper.xSignatureStream = aHelper.xSignatureStorage->openStreamElement( aSIGStreamName, nOpenMode ); } } |