Is there any way to force Aspose.Pdf to create external signature using SHA256 hash? We have problem signing documents with Aspose.Pdf using cloud hosted signing service (CryptoTech CloudSigner with mSzafir provider). The same problem has been already reported to you two years ago: (Problem with signing PDF file when using cert with privatekey stored on external card)
The call to the SignHash method of RSACryptoServiceProvider seems to be using SHA1 algorithm and there is no way to force SHA256 here (data provided by Aspose.Pdf to this method is incompatible with SHA256). Unfortunatelly SHA1 algorithm is no longer supported by CSP due to security concerns.
We’re using Aspose.Pdf latest 22.2 version
Exception message: ‘One or more of the supplied parameters could not be properly interpreted’
Stack trace:
w System.Security.Cryptography.Utils.SignValue(SafeKeyHandle hKey, Int32 keyNumber, Int32 calgKey, Int32 calgHash, Byte[] hash, Int32 cbHash, ObjectHandleOnStack retSignature)
w System.Security.Cryptography.Utils.SignValue(SafeKeyHandle hKey, Int32 keyNumber, Int32 calgKey, Int32 calgHash, Byte[] hash)
w System.Security.Cryptography.RSACryptoServiceProvider.SignHash(Byte[] rgbHash, Int32 calgHash)
w System.Security.Cryptography.RSACryptoServiceProvider.SignHash(Byte[] hash, HashAlgorithmName hashAlgorithm, RSASignaturePadding padding)
w PdfAsposeTest.VulcanCryptoServiceProvider.SignHash(Byte[] hash, HashAlgorithmName hashAlgorithm, RSASignaturePadding padding) w C:\WORK\PdfAspose\PdfAsposeTest\VulcanCryptoServiceProvider.cs:wiersz 73
w System.Security.Cryptography.RSAPKCS1SignatureFormatter.CreateSignature(Byte[] rgbHash)
w #=zTg6_Hdjaf3SiPtI$wnmd0hqR$jC_cQUoJQ==.#=zmwjQ$nU=.#=zHYIzMTs=(Byte[] #=zmy1MFow=, #=zm1ec9qZqkEgyj0L3OgoQQS8M_L5iYq2HdInZ8hg= #=zk0PKLEc=, OcspSettings #=zcMgUJst1cvcB, TimestampSettings #=zL5AFIUO5TqJQ, Boolean #=z0T0VkD0=, X509Certificate2 #=zx2e$J0qbBvTy)
w #=zTg6_Hdjaf3SiPtI$wnmd0hqR$jC_cQUoJQ==.#=zmwjQ$nU=.#=zsw6uCpM=(Byte[] #=zmy1MFow=, X509Certificate2 #=zx2e$J0qbBvTy, OcspSettings #=zcMgUJst1cvcB, TimestampSettings #=zL5AFIUO5TqJQ, Boolean #=z0T0VkD0=)
w #=zTg6_Hdjaf3SiPtI$wnmd0hqR$jC_cQUoJQ==.#=zmwjQ$nU=.#=zsw6uCpM=(Byte[] #=zmy1MFow=, X509Certificate2 #=zx2e$J0qbBvTy, OcspSettings #=zcMgUJst1cvcB, TimestampSettings #=zL5AFIUO5TqJQ)
w #=zTg6_Hdjaf3SiPtI$wnmd0hqR$jC_cQUoJQ==.#=zmwjQ$nU=.#=zsw6uCpM=(Byte[] #=zmy1MFow=, X509Certificate2 #=zx2e$J0qbBvTy)
w #=zrecUuf4Mea8RNCMZBiiD7$0WI_Mt.#=zsw6uCpM=(#=zklR7lxUuz8iQbde7HzYawJdEKEqGdG$4pRlD7YNWQJlL #=zy3$g_gj3PQ7z, Boolean #=zmWMzbnDYbnC4, #=z9SgYabW0TLL$mgFSEuqJ0lv_LkZzPJdhCQ== #=z92nYEoQ=, #=zM$ku6EoeSHU5Kf0ithn7ZLhJRejCpd$RWw== #=zYyZSylk=, #=zKogmA92ENCsIFT2Gn5jaeF$v3apo7Rdskg== #=zaXCrDOo=, Stream #=zk0PKLEc=, String #=zv2xHVB8=, X509Certificate2 #=zx2e$J0qbBvTy, String& #=zDWpqUWY=, Int32& #=zje8ZSvgT6Cde)
w #=zrecUuf4Mea8RNCMZBiiD7$0WI_Mt.#=zsw6uCpM=(String #=zqZGIh$U=, #=zM$ku6EoeSHU5Kf0ithn7ZLhJRejCpd$RWw== #=zYyZSylk=, #=zKogmA92ENCsIFT2Gn5jaeF$v3apo7Rdskg== #=zaXCrDOo=, Stream #=zk0PKLEc=, String #=zv2xHVB8=, X509Certificate2 #=zx2e$J0qbBvTy)
w #=zrecUuf4Mea8RNCMZBiiD7$0WI_Mt.#=zsw6uCpM=(String #=zqZGIh$U=, #=zM$ku6EoeSHU5Kf0ithn7ZLhJRejCpd$RWw== #=zYyZSylk=, #=zKogmA92ENCsIFT2Gn5jaeF$v3apo7Rdskg== #=zaXCrDOo=, X509Certificate2 #=zx2e$J0qbBvTy)
w Aspose.Pdf.Forms.Signature.#=zsw6uCpM=(String #=zqZGIh$U=, Stream #=zk0PKLEc=, String #=zv2xHVB8=)
w Aspose.Pdf.Forms.SignatureField.Sign(Signature signature, Stream pfx, String pass)
w Aspose.Pdf.Forms.SignatureField.Sign(Signature signature)