mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-07-11 22:03:01 -06:00
PdfDraw: Invisible signatures fixed
git-svn-id: svn://ultimatepp.org/upp/trunk@10366 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
fbdcba2855
commit
53e2c5cc57
2 changed files with 4 additions and 63 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue