[poppler] utils/pdfsig.cc
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Wed Dec 29 16:44:07 UTC 2021
utils/pdfsig.cc | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
New commits:
commit 405b7ce25e8e557d98dd299f6ecd8f1b795bf50a
Author: Albert Astals Cid <aacid at kde.org>
Date: Wed Dec 29 11:27:35 2021 +0100
pdfsig: Add support for listing signatures of documents with passwords
Adding signatures to documents with passwords still doesn't work
diff --git a/utils/pdfsig.cc b/utils/pdfsig.cc
index a1579478..e2d6bff2 100644
--- a/utils/pdfsig.cc
+++ b/utils/pdfsig.cc
@@ -127,6 +127,8 @@ static bool dumpSignature(int sig_num, int sigCount, FormFieldSignature *s, cons
static GooString nssDir;
static GooString nssPassword;
+static char ownerPassword[33] = "\001";
+static char userPassword[33] = "\001";
static bool printVersion = false;
static bool printHelp = false;
static bool dontVerifyCert = false;
@@ -158,6 +160,8 @@ static const ArgDesc argDesc[] = { { "-nssdir", argGooString, &nssDir, 0, "path
{ "-digest", argString, &digestName, 256, "name of the digest algorithm (default: SHA256)" },
{ "-reason", argGooString, &reason, 0, "reason for signing (default: no reason given)" },
{ "-list-nicks", argFlag, &listNicknames, 0, "list available nicknames in the NSS database" },
+ { "-opw", argString, ownerPassword, sizeof(ownerPassword), "owner password (for encrypted files)" },
+ { "-upw", argString, userPassword, sizeof(userPassword), "user password (for encrypted files)" },
{ "-v", argFlag, &printVersion, 0, "print copyright and version info" },
{ "-h", argFlag, &printHelp, 0, "print usage information" },
{ "-help", argFlag, &printHelp, 0, "print usage information" },
@@ -265,8 +269,15 @@ int main(int argc, char *argv[])
std::unique_ptr<GooString> fileName = std::make_unique<GooString>(argv[1]);
+ std::unique_ptr<GooString> ownerPW, userPW;
+ if (ownerPassword[0] != '\001') {
+ ownerPW = std::make_unique<GooString>(ownerPassword);
+ }
+ if (userPassword[0] != '\001') {
+ userPW = std::make_unique<GooString>(userPassword);
+ }
// open PDF file
- std::unique_ptr<PDFDoc> doc(PDFDocFactory().createPDFDoc(*fileName, nullptr, nullptr));
+ std::unique_ptr<PDFDoc> doc(PDFDocFactory().createPDFDoc(*fileName, ownerPW.get(), userPW.get()));
if (!doc->isOk()) {
return 1;
More information about the poppler
mailing list