-
Notifications
You must be signed in to change notification settings - Fork 39
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
Cryptographic signature verification has failed - issue during signature finalize #135
Comments
Hello, Cryptographic signature verification failure indicates that the signature you provided fails to validate against the public key of your certificate. This could have many reasons, including:
At the following line of your code: signatureDTO.setBase64Signature(digestDTO.getHash()); What does At the following line of your code: byte[] signatureBytes = DatatypeConverter.parseBase64Binary(signatureDTO.getBase64Signature()); How is the signature, returned by Is the signature creation implemented in Java or is the signing done remotely using some other means? The exact way to sign the input data depends on the tool that you are using. For example, in case of using Signature signature = Signature.getInstance("SHA256withRSA"); // or "SHA256withECDSA"
signature.init(yourPrivateKey); // Initialize the signature with your private key
signature.update(dataToSign.getDataToSign()); // Provide the raw, un-hashed input
return signature.sign(); But if you calculate the digest of the data-to-sign yourself, then you must use signature algorithms like Signature signature = Signature.getInstance("NONEwithECDSA");
signature.init(yourPrivateKey); // Initialize the signature with your private key
signature.update(digest); // Provide the digest that you have calculated
return signature.sign(); NB: Signature signature = Signature.getInstance("NONEwithRSA");
signature.init(yourPrivateKey); // Initialize the signature with your private key
signature.update(dataToSign.getDigestAlgorithm().digestInfoPrefix()); // Prepend the digest with padding
signature.update(digest); // Append the digest that you have calculated
return signature.sign(); * The digest algorithm in the above examples has been chosen based on your example code. When using a different digest algorithm, adapt the examples accordingly. |
Hello, I managed to resolve the issue, but now I am encountering another problem with the I have checked the GitHub link but haven't found the solution. I use a self-signed certificate, and the configuration mode is set to TEST.
Thank you |
If you need to test the signing I suggest you use keystore that is already made for testing purposes in DD4J project (you can see references and pins):
These keystores work out of the box with DD4J in TEST mode and can be used for testing purposes. Using your own certificate for LT profile signature means that the issued certificate profile must match all the requirements, it must be trusted (present in TSL or trusted programmatically together with all needed qualifiers) and must have valid OCSP response. Fullfilling all these conditions with self issued certificates requires specific knowledge and is not easily achieved. |
Hi all,
I am developing a simple digital signing application and closely followed the documentation. However, when I attempt to
finalize the signature using the finalize method from the DataToSign class, I encounter the following error:
eu.europa.esig.dss.model.DSSException: Cryptographic signature verification has failed / Signature verification failed against the best candidate.
I am using a self signed x509 certificate generated on my windows machine.
Thanks in advance.
The text was updated successfully, but these errors were encountered: