Open WindowsNT opened 7 years ago
After some hassling I managed to do 2 fixes:
In newSig() I changed
var offsetForm = find(pdf.stream.bytes, '<<', root.offset) + 2;
removing the 3rd parameter... it can now sign some pdf files, but not the one from TCPDF.
Hello @WindowsNT, Can you propose a pull request for the project? :-) Then we would test it and probably incorporate to the repo.
Hi guys... @WindowsNT any advance?
-A PDF created directly from last version of Adobe Acrobat ---> Invalid PDF -The same PDF but after, opened it with Firefox -> Print -> Save as PDF ---> Valid PDF
I have fixed my issue, but it is tcpdf pdf files I am generating, not any pdf.
Hi, I was able to sign pdf with your mycert-1.p12 certificate, but when I try to sign same pdf with my (czech) p12 cert or with my sample kazakh cert acrobat reader says that signature has errors in formatting or in signature data. When I sign same pdf with these certificates in Java using iText library no errors are displayed. Has PDFSign any limitations? Eg encoding of diacritics in key properties? Or do you have any clue what is causing this problem?
Hi @shebik What does your (czech) p12 cert look likes?? In order to use this lib, your p12 cert should only contain your cert and priv key. If your p12 cert contains another cert (e.g. CA cert), you should repack your p12 cert which only contain your cert and priv key on it. Then it must be working now.
Regards,
Hi Everyone, @WindowsNT @gsmachado @shebik @anfuca @argapramudianto
I am able to sign pdf but I get invisible signature on the page. I am trying to bring that sign (watermark). Even example pdf of this repository have that watermark for signed pdfs. Do I have to change the code for this. Is this invisible by default? Can you please help me on this?
Thanks
Would like to use this. Have you guys been able to make it work?
I'm also interested in this. Any success in getting the signature to appear?
No progress on my side. I want to use this in a node.js Environment. Are there any alternatives?
Unfortunately, at the moment, I don't have plenty of time to provide the fix. However, I'm more than welcome to receive and analyze a pull request.
Hi @argapramudianto ! it is possible to extract my certificate from the PKCS12 file and create a new PKCS12 file (with the private key and only my certificate) to sign, from javascript.
In theory it is, I'm using forge, which seems to have this feature: https://github.com/digitalbazaar/forge#pkcs12
@tbocek: I add this inside the method sign in pdfsign.js:
function sign(data, rawpdf, password, date) {
...
var p7 = forge.pkcs7.createSignedData();
p7.content = forge.util.createBuffer(rawpdf);
var last = bags[certBag][0];
var first = pki.certificateToPem(bags[certBag][0].cert);
p7.addCertificate(bags[certBag][0].cert);
// get key bags
var bags = p12.getBags({bagType: keyBag});
// get key
var bag = bags[keyBag][0];
var key = bag.key;
// Generate new P12
var newP12asn1 = forge.pkcs12.toPkcs12Asn1(
key, first, 'vTemBJHYMd');
var newp12 = forge.pkcs12.pkcs12FromAsn1(newP12asn1, false, 'vTemBJHYMd');
...
}
I try use the newP12 file to sign but does not work. After i download it and i try to open the newP12 file and is corrupt. Do you have any idea about? Thanks in advance.
I 'm struggling to sign a PDF in javascript and I found this. However, it always outputs an invalid PDF. Either unreadable (header incorrect), or unsigned with invalid signature entry as read by adobe reader.
I am attaching the two pdf files I 'm trying. The 00 one is generated by TCPDF.
0.pdf 00.pdf