fix: omit KeyInfo when there is no content for it - #597
Conversation
XMLDSig requires KeyInfo and X509Data to each have at least one child element. The default getKeyInfoContent returned an empty X509Data when publicCert held no certificate, and setting keyInfoAttributes without any content wrote the text "null" into KeyInfo. Closes node-saml#596 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
Warning Review limit reachedNext included review available in 2 minutes. View limit detailsLimit details: You’ve used all 2 included reviews currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (3)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #597 +/- ##
==========================================
+ Coverage 75.95% 79.96% +4.01%
==========================================
Files 9 9
Lines 1048 1118 +70
Branches 273 283 +10
==========================================
+ Hits 796 894 +98
+ Misses 144 129 -15
+ Partials 108 95 -13 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Closes #596
XMLDSig's schema requires
KeyInfo(4.5) andX509Data(4.5.4) to each contain at least one child element. Signing could produce either one empty:publicCerthas noBEGIN CERTIFICATEblock, e.g. a PEM public key<KeyInfo><X509Data/></KeyInfo>KeyInfokeyInfoAttributesset, nopublicCert<KeyInfo Id="key">null</KeyInfo>KeyInfoChanges
SignedXml.getKeyInfoContentreturnsnullwhenpublicCertcontains no certificate. Its JSDoc already definesnullas "noKeyInfoelement should be included".getKeyInfo()emitsKeyInfoonly whengetKeyInfoContentreturns content.keyInfoAttributesalone no longer produce an element.Compatibility
This targets v6.2 and does not throw. The issue notes that throwing when
keyInfoAttributesare set with no content would be more explicit, but it would break configurations that sign today, so that choice is left for 7.0.A caller who set
keyInfoAttributeswith no content and added a reference toKeyInfonow gets the existing "xpath cannot be signed because it was not found" error instead of a signature over<KeyInfo>null</KeyInfo>.Tests
Two regression tests sign with each configuration and check that the signature has no
KeyInfo. Both failed before the fix because aKeyInfoelement was present.🤖 Generated with Claude Code