From b1434b95d15d5e7246b3c657a68f87445eede513 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Tue, 25 Oct 2016 19:55:16 +0200 Subject: [PATCH] xmlsecurity PDF sign: use unique ID for a new signature Otherwise Adobe Acrobat thinks they are different versions of the same signature. Change-Id: I454c7d87106e348fd70f18fad83f2c3aeda29dff Reviewed-on: https://gerrit.libreoffice.org/30278 Reviewed-by: Miklos Vajna Tested-by: Jenkins --- xmlsecurity/source/pdfio/pdfdocument.cxx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/xmlsecurity/source/pdfio/pdfdocument.cxx b/xmlsecurity/source/pdfio/pdfdocument.cxx index dfd3938984a2..fc942c1c5ecb 100644 --- a/xmlsecurity/source/pdfio/pdfdocument.cxx +++ b/xmlsecurity/source/pdfio/pdfdocument.cxx @@ -297,6 +297,10 @@ bool PDFDocument::RemoveSignature(size_t nPosition) bool PDFDocument::Sign(const uno::Reference& xCertificate, const OUString& rDescription) { + // Decide what identifier to use for the new signature. + std::vector aSignatures = GetSignatureWidgets(); + sal_uInt32 nNextSignature = aSignatures.size() + 1; + m_aEditBuffer.WriteCharPtr("\n"); // Write signature object. @@ -368,7 +372,9 @@ bool PDFDocument::Sign(const uno::Reference& xCertificat m_aEditBuffer.WriteCharPtr("/P "); m_aEditBuffer.WriteUInt32AsString(pFirstPage->GetObjectValue()); m_aEditBuffer.WriteCharPtr(" 0 R\n"); - m_aEditBuffer.WriteCharPtr("/T(Signature1)\n"); + m_aEditBuffer.WriteCharPtr("/T(Signature"); + m_aEditBuffer.WriteUInt32AsString(nNextSignature); + m_aEditBuffer.WriteCharPtr(")\n"); m_aEditBuffer.WriteCharPtr("/V "); m_aEditBuffer.WriteUInt32AsString(nSignatureId); m_aEditBuffer.WriteCharPtr(" 0 R\n");