diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-10-14 10:41:34 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-10-14 12:21:10 +0200 |
commit | 876fcb5461bb1fdb151a4457ccacaed6904238a2 (patch) | |
tree | f9e6273e07c990bd23c05b7b05ffd070b19f01d2 | |
parent | 4cb720836ab03701ce508e302790c115c7808619 (diff) |
xmlsecurity: expose date of PDF signatures
It's a UTC UNIX timestamp, in microseconds.
Change-Id: I1dad7fd6b7e68e85275219208affc890f48975d1
-rw-r--r-- | xmlsecurity/source/pdfio/pdfdocument.cxx | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/xmlsecurity/source/pdfio/pdfdocument.cxx b/xmlsecurity/source/pdfio/pdfdocument.cxx index 22731dbbbb63..225c588501fc 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) |