[Libreoffice-commits] core.git: xmlsecurity/source

Miklos Vajna vmiklos at collabora.co.uk
Wed Oct 26 07:05:09 UTC 2016


 xmlsecurity/source/pdfio/pdfdocument.cxx |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

New commits:
commit b1434b95d15d5e7246b3c657a68f87445eede513
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Tue Oct 25 19:55:16 2016 +0200

    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 <vmiklos at collabora.co.uk>
    Tested-by: Jenkins <ci at libreoffice.org>

diff --git a/xmlsecurity/source/pdfio/pdfdocument.cxx b/xmlsecurity/source/pdfio/pdfdocument.cxx
index dfd3938..fc942c1 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<security::XCertificate>& xCertificate, const OUString& rDescription)
 {
+    // Decide what identifier to use for the new signature.
+    std::vector<PDFObjectElement*> 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<security::XCertificate>& 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");


More information about the Libreoffice-commits mailing list