xmlsecurity/source/pdfio/pdfdocument.cxx | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)
New commits: commit 876fcb5461bb1fdb151a4457ccacaed6904238a2 Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Fri Oct 14 10:41:34 2016 +0200 xmlsecurity: expose date of PDF signatures It's a UTC UNIX timestamp, in microseconds. Change-Id: I1dad7fd6b7e68e85275219208affc890f48975d1 diff --git a/xmlsecurity/source/pdfio/pdfdocument.cxx b/xmlsecurity/source/pdfio/pdfdocument.cxx index 22731db..225c588 100644 --- a/xmlsecurity/source/pdfio/pdfdocument.cxx +++ b/xmlsecurity/source/pdfio/pdfdocument.cxx @@ -15,12 +15,16 @@ #include <com/sun/star/uno/Sequence.hxx> +#include <comphelper/processfactory.hxx> #include <comphelper/scopeguard.hxx> #include <rtl/strbuf.hxx> #include <rtl/string.hxx> #include <sal/log.hxx> #include <sal/types.h> #include <sax/tools/converter.hxx> +#include <unotools/calendarwrapper.hxx> +#include <unotools/datetime.hxx> +#include <xmloff/xmluconv.hxx> #ifdef XMLSEC_CRYPTO_NSS #include <cert.h> @@ -860,6 +864,28 @@ bool PDFDocument::ValidateSignature(SvStream& rStream, PDFObjectElement* pSignat rInformation.ouX509Certificate = aBuffer.makeStringAndClear(); } + PRTime nSigningTime; + if (NSS_CMSSignerInfo_GetSigningTime(pCMSSignerInfo, &nSigningTime) != SECSuccess) + { + SAL_WARN("xmlsecurity.pdfio", "PDFDocument::ValidateSignature: NSS_CMSSignerInfo_GetSigningTime() failed"); + return false; + } + else + { + // First convert the UNIX timestamp to an ISO8601 string. + OUStringBuffer aBuffer; + uno::Reference<uno::XComponentContext> xComponentContext = comphelper::getProcessComponentContext(); + CalendarWrapper aCalendarWrapper(xComponentContext); + // nSigningTime is in microseconds. + SvXMLUnitConverter::convertDateTime(aBuffer, static_cast<double>(nSigningTime) / 1000000 / tools::Time::secondPerDay, aCalendarWrapper.getEpochStart().GetUNODate()); + + // Then convert this string to a local UNO DateTime. + util::DateTime aUNODateTime; + utl::ISO8601parseDateTime(aBuffer.toString(), aUNODateTime); + DateTime aDateTime(aUNODateTime); + aDateTime.ConvertToLocalTime(); + rInformation.stDateTime = aDateTime.GetUNODateTime(); + } SECItem* pContentInfoContentData = pCMSSignedData->contentInfo.content.data; if (pContentInfoContentData && pContentInfoContentData->data) _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits