-
Notifications
You must be signed in to change notification settings - Fork 189
feat: Support formatted SignatureValue and lenient verification #507
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
base: master
Are you sure you want to change the base?
feat: Support formatted SignatureValue and lenient verification #507
Conversation
Introduces options to format the SignatureValue and makes the verification process more resilient to whitespace differences. Some XML signature implementations, particularly in Java, format the base64-encoded SignatureValue with line breaks and carriage returns (e.g., at every 76th character). The previous implementation produced a single-line value and expected the same during verification, leading to interoperability failures. This commit addresses the issue in two ways: 1. A new `signatureValueFormatting` option is added, allowing the caller to specify a line length and choose between LF and CRLF line endings for the generated signature. 2. The `loadSignature` method now strips all whitespace characters from the SignatureValue content, making verification resilient to any formatting differences. Closes node-saml#486
Out of curiosity: which other java libraries (other than The way I read (*) content of links (and transitive links) provided at #486 (comment) is that it was java side mistake/regression which is now taken care of. Affected versions listed at https://bugs.openjdk.org/browse/JDK-8264194 are At the time latest java8 seems to be 8u451 and latest java11 11.0.27 So, (if) things have settled down at java side why introduce workaround to xml-crypto side (i.e. more code to be maintained) especially if workaround is for something that is fixed/fixable at java side if those systems are kept running on top of up to date java8/java11/java... (if those systems provide security related services those should be running on top of latest supported 8/11/...) (*) I am NOT saying that I am 100% sure that I read those correctly. |
FWIW, seems that e.g. Keycloak fixed behavioral change of Have you asked from your counterpart whether it can set Interesting note at SANTUARIO-482 |
Thank you for the research. |
@jlucaso1 , I'm with @srd90 on this one. That is a lot of code to deal with what appears to be a straight-forward issue. Your proposal to simply remove whitespace seems a little more reasonable, but one has to wonder, why would there be whitespace in a signature that we trust? Is some library generating signatures with whitespace in them? |
@jlucaso1 asked:
AFAIK xml-crypto hasn't had any issues with E.g. |
Closes #486
This PR resolves an interoperability issue with XML signatures generated by some Java libraries (like
javax.xml.crypto.dsig
). These libraries often format the<ds:SignatureValue>
with line breaks and carriage returns (
), which caused validation failures when checked with the current implementation.This is addressed with two key changes:
Flexible Signature Formatting: A new
signatureValueFormatting
option has been added toSignedXmlOptions
. This allows developers to configure the line length and line endings to match the output of other systems, ensuring compatibility.Resilient Signature Verification: The signature loading logic has been updated to strip all whitespace from the
<ds:SignatureValue>
during parsing. This ensures that validation succeeds regardless of how the signature is formatted (single-line vs. multi-line).