Help with PKCS7
#1287
Replies: 1 comment
-
Yes, I think so. Does this code work for you?
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I have a server attached to an HSM that I want to use to generate PKCS7 for a PDF. Basically the client generates an SHA-256 digest and the server creates the SignedAttributes, signs them with its key, and returns the resulting PKCS7 for the client to insert into the PDF.
But I'm running into a problem where the PDF doesn't verify and I cannot understand why. Here's the code I'm using to create what I think should be a valid signature:
Basically, I load the certificate from the HSM and get a PrivateKey that represents the private key (which remains locked away in the HSM). The pdfDigestBytes are the sha256 digest calculated by the client (I have manually verified these by splicing together the PDF minus the placeholder with two
dd
invocations and sending it tosha256sum
and the digest matches). The resulting DER is exactly what I would expect. I can see a call to the HSM, although it's forSha256WithRsaSignature
which isn't what I was expecting, since the resulting DER says it containsRSA
.I spliced apart the DER, pulled out the signedAttributes, signature, and certificate, and tried to verify the signature using openssl, and sure enough it doesn't verify.
If I use a test harness to create a PKCS7 and then immediately verify it using keys generated with BouncyCastle, the verification fails.
Am I using the API incorrectly? Is this even achievable?
Beta Was this translation helpful? Give feedback.
All reactions