-
-
Notifications
You must be signed in to change notification settings - Fork 188
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PKCS#11 put already signed data to pdf signature #15
Comments
I cannot at the moment spend much time to research more on it. I don't even know what PKCS11 is. If you look at my code you will see how it works basically. I've tried to explain it in the readme as well.
|
Some references: Basically explained, PKCS#11 is a interface to manipulate the device with cryptograpy data (SmartCards, etc..) and you extract the keys using that interface to sign your data (using this interface to extract the private key to sign), in your implementation you directly need to pass the p12 cert file, and through node-forge you build the signed data.. Actually i have the signed data, and just need to put in PDF. Following the logic you explain, i think the flux is the same, but i don't have any experience in manipulate PDF data like that, today i'm going to code based in your code to find some light, thank you! Java Code that actually working for both (.p12 and devices that implement PKCS#11):
|
Hope you'll be able to sign it. You may need to slightly alter the code of this lib as from your description you already have the crypto-needed data it is not just packed in the PKCS#12 way. We already had an idea (#12 (comment)) to support other ways of providing signing data so if you have something workable, would love to see it. Let us know if you have any progress and/or issues. |
@ankology did it work out well at the end? Now that I read your latest comment, it seems to me that you only needed to do some basic string manipulations to get it wrapped up. Is that correct? Did you succeed? Was this lib of any help? |
@vbuch Hello! I am currently working on other projects, when I come back to work on it and some progress occurs I will tell here! |
I'm sorry to wake-up the old thread. We are also working on the solution of PKCS11 - HSM based PDF signing. We used graphene-pk11 for PKCS11 operation and absolutely works fine. Sample Code to sign.
Kindly help me on achieving the same for PDF stream and attaching the PKCS7 into the Final PDF. |
Oh. That's a totally different thing. If you implement it, I imagine it could be reused in this package with two adapters. One is the p12 that this package already has implemented and the p11 would be your code. The tricky part is that reqiures mostly understanding detached signatures. Other than that is should not be much different. You still have the input content (PDF), you need to create a digest of that (https://github.com/vbuch/node-signpdf/blob/master/src/signpdf.js#L139) and then extract the signature for that digest. Actually this is what "signing in detached mode means": The content is not included in the Signature but rather only a digest of the content. |
Oh, man! Now, having a gemalto e-sign, I'm really curious if and how this could work. Whenevr I have time, I would give it a shot to at least experiment with graphene-pk11. |
Above solution uses graphene-pk11. Now, I can sign the PDF as follows.,
But, I need to attach the certificate and other attributes as you did it using forge. Kindly help me on this. |
Hi guys, i'm back this week to the project that uses this functionality but i didn't come to that part in the system .. Basically the app runs in electron, and through javascript i need to sign that PDF file and put the signature on it, today i already have the buffer signed! But i need to attach the signed data to the PDF.
Current code (prototype from past year at november 2018):
So, when i back to code the idea is to put directly these already signed data into the PDF (in its structure placement to signatures) based in your code library what does the same using p12 certificate and that's it! |
@vbuch i'm looking the source code and at file/line /src/signpdf.js the method p7.toAsn1() do what in fact? And what is a detached pkcs7 signature in fact? Thanks! Edit: issue closed unintentionally 😆😆!! |
I may try to explain, but in fact, the idea of this package is to figure it out yourself with a little help in the way. So here come the links that are the "little help".
PKCS7: https://www.npmjs.com/package/node-forge#pkcs7
https://docs.oracle.com/cd/E19398-01/820-1228/gfnmj/index.html |
No activity. Closing. |
can we use this code for digital pdf sign any other source where i can find it |
Hi Valery! Thank you by the project.
I need to sign data using a SmartCard Token, that implements PKCS#11 layer, i already have a working implementation using NodeJS (Migrating from a Java implementation) to sign the data based on some PDF binary, now i need to put this signed data in the PDF, i take a look to your code and i need to ask, to solve my issue, i just need to replace the signed data (generated by node-forge based on .pfx) by my signed data (generated from my current implementation, that already signed with PDF binary and the Token PKCS#11) in code? Thats it? I have spent time to find some PKCS#11 solution to NodeJS but i didn't found pratically nothing, and all PDF libraries have only support to p12|pfx, thank you!
The text was updated successfully, but these errors were encountered: