Skip to content
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

Invalid Signature (internal cryptographic library 0x2726) when viewed the sign pdf #8

Closed
Ford49 opened this issue Jul 5, 2019 · 11 comments

Comments

@Ford49
Copy link

Ford49 commented Jul 5, 2019

This warning give me while signing pdf documents
ATTENTION: The pdf has been modified after at least a signature!
Please help me Sir

@damianofalcioni
Copy link
Owner

try to check for problems with the internal diagnostic utils:
Right click in the tray icon and press the "Check Problems" button. Maybe a conflicting bouncy castle library is in the java classpath.
If not try to use a different Java version like the Java6

@Ford49
Copy link
Author

Ford49 commented Jul 9, 2019

Sir there is no conflict with the library and i have change to java 6 but the same problem occurs

@damianofalcioni
Copy link
Owner

You can try recompiling commenting that line: SignEngine.java L165
This will skip the generated signature verification process. After you can check with another tool if the signature is correct or not. If is correct then there is an error in the verification process. If is not correct there is a problem in the signature process.

@Ford49
Copy link
Author

Ford49 commented Jul 9, 2019

It still gives me invalid signature
First Error encountered:
1)Impossible to perform a valid signature with the following certificate and libraries
Certificate: 'CN=XXXX, SERIALNUMBER=XXXX, ST=XXX, OID.2.5.4.17=XXXX, OU="XXXX,CID - XXX", OID.2.5.4.20=XXX, O=XX, C=XXX'
Libraries:
C:\WINDOWS\System32\SignatureP11.dll
2)I comment the exception line error 1 and I return certData it then give me the following error
ATTENTION: The pdf has been modified after at least a signature!
of course I can save the signed pdf but it was invalid
3)I have skipped the verification process still gives me invalid signature
:(

@damianofalcioni
Copy link
Owner

So the problem was not in the verification but in the certificate used for the signature!
You need to debug this function SignEngine.java#L181 and try to understand why your certificate is not recognized as valid for signature.
Probably your card did not support SHA256WithRSA but have a look at the debug and the catch clause.

@Ford49
Copy link
Author

Ford49 commented Jul 9, 2019

Yes Probably
Sir,Is there any other alternatives sir that could make this work?

@damianofalcioni
Copy link
Owner

Yes of course.
You just have to change the code trying different signature methods in order to find the one supported by your card. You may also need to use another digestOIDToUse parameter.
Good luck and do a pull request in case of success!

@Ford49
Copy link
Author

Ford49 commented Jul 18, 2019 via email

@damianofalcioni
Copy link
Owner

Hi,
sorry but this is not possible. The software is provided "as is" without warranty as it is open sourced under GNU Affero license. I did not provide commercial support.
Anyway as already said the solution to your problem is really simple. You have to use SHA1WithRSA instead of the current SHA256WithRSA signature method, so replace all this strings. Also change all the CMSSignedDataGenerator.DIGEST_SHA256 to CMSSignedDataGenerator.DIGEST_SHA1 and it should work!

@damianofalcioni
Copy link
Owner

damianofalcioni commented Jul 18, 2019

Sorry, wrong suggestion. It is more convenient for you to uncomment the main method in SmartCardAccessJnaImpl.java (change the DLL path and provide the PIN as second argument of the cardManager.login function), execute it and check if also here the signature is invalid. Then debug from this point.

@Ford49
Copy link
Author

Ford49 commented Jul 24, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants