From 53e2c5cc578d9e97dc4dc3e936d600275e329f07 Mon Sep 17 00:00:00 2001 From: cxl Date: Thu, 27 Oct 2016 07:46:26 +0000 Subject: [PATCH] PdfDraw: Invisible signatures fixed git-svn-id: svn://ultimatepp.org/upp/trunk@10366 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/Core/SSL/P7S.icpp | 59 -------------------------------------- uppsrc/PdfDraw/PdfDraw.cpp | 8 +++--- 2 files changed, 4 insertions(+), 63 deletions(-) diff --git a/uppsrc/Core/SSL/P7S.icpp b/uppsrc/Core/SSL/P7S.icpp index 9ef18cfd6..eba588a9d 100644 --- a/uppsrc/Core/SSL/P7S.icpp +++ b/uppsrc/Core/SSL/P7S.icpp @@ -2,7 +2,6 @@ namespace Upp { -#if 1 String GetP7Signature_imp(const void *data, int length, const String& cert_pem, const String& pkey_pem) { SslCertificate x509; @@ -36,64 +35,6 @@ String GetP7Signature_imp(const void *data, int length, const String& cert_pem, return r; } -#else - -String GetP7Signature_imp(const void *data, int length, const String& cert_pem, const String& pkey_pem) -{ - SslCertificate x509; - SslKey pkey; - if(!x509.Load(cert_pem)) - return Null; - if(!pkey.Load(pkey_pem)) - return Null; - - DDUMP(length); - - String infilename = GetHomeDirFile("p7.in"); - String outfilename = GetHomeDirFile("p7.out"); - { FileOut fo(infilename); fo.Put(data, length); } - - BIO *infile = BIO_new_file(infilename, "r"); - BIO *outfile = BIO_new_file(outfilename, "w"); - - int flags = PKCS7_DETACHED|PKCS7_BINARY|PKCS7_STREAM; - - PKCS7 *p7 = PKCS7_sign(x509, pkey, NULL, infile, flags); - - if (!p7) - return Null; - - SslStream out; - out.CreateBuffer(); - - String r; - if(SMIME_write_PKCS7(outfile, p7, infile, flags)) { - BIO_free(outfile); - String s = LoadFile(outfilename); - DDUMP(s); - int p1 = s.FindAfter("Content-Disposition: attachment; filename=\"smime.p7s\""); - if(p1 >= 0) { - int p2 = s.Find("----", p1); - if(p2 >= 0) { - DDUMP(p1); - DDUMP(p2); - DDUMP(s.Mid(p1, p2 - p1)); - r = Base64Decode(s.Mid(p1, p2 - p1)); - DDUMP(r.GetCount()); - } - } - } - else - BIO_free(outfile); - - PKCS7_free(p7); - BIO_free(infile); - - return r; -} - -#endif - extern String (*GetP7Signature__)(const void *data, int length, const String& cert_pem, const String& pkey_pem); INITBLOCK { diff --git a/uppsrc/PdfDraw/PdfDraw.cpp b/uppsrc/PdfDraw/PdfDraw.cpp index 627638b80..7b168a1f9 100644 --- a/uppsrc/PdfDraw/PdfDraw.cpp +++ b/uppsrc/PdfDraw/PdfDraw.cpp @@ -1031,7 +1031,7 @@ String PdfDraw::Finish(const PdfSignatureInfo *sign) } } - if(sign) { // add invisible signature + if(sign) { signature_widget = BeginObj(); out << "<< /Type /Annot\n" "/Subtype /Widget\n" @@ -1039,15 +1039,15 @@ String PdfDraw::Finish(const PdfSignatureInfo *sign) "/Ff 0\n" // not sure what is this... "/T(Signature)\n" "/V " << signature << " 0 R\n" - "/P " << signature_widget + 2 + sign_page << " 0 R\n" // next entry is Pages and then Page ; - if(IsNull(sign_page)) { + if(IsNull(sign_page)) { // invisible signature out << "/F 132 /Rect[0 0 0 0]\n"; sign_page = 0; } else out << "/F 4 " << sign_rect; - out << ">>\n"; + out << "/P " << signature_widget + 2 + sign_page << " 0 R\n" // next entry is Pages and then Page + << ">>\n"; EndObj(); }