Skip to content

Sign PDF with custom CMS via SignedDataCreator (PKCS#11) #314

Answered by gettalong
nanowind asked this question in Q&A
Discussion options

You must be logged in to vote

It does exactly what it says: If the certificate key is not provider, HexaPDF can't sign the digest. Therefore it yields the digest algorithm that is used by the signed data creator and the hash that should be signed. The responsible of the caller is that it returns the signed hash. A simple implementation where key is an OpenSSL private key would be this:

external_signing = lambda do |digest_algorithm, hash|
  key.sign_raw(digest_algorithm, hash)
end

From what I see from your code you are already doing this with PKCS11RSAPrivateKey. One thing I don't understand in your code is the creation of the pdf_temp part. This is not necessary as it would mean that you are signing the PDF twice.

C…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@nanowind
Comment options

@nanowind
Comment options

Answer selected by nanowind
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants