Skip to content
Open
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
5200d71
feat: add XmlDSigVerifier wrapper for SignedXml
shunkica Oct 25, 2025
92eb417
fix: Support nested enveloped signature location (#525)
shunkica Dec 28, 2025
23d8b14
refactor: clean up types and use array-based algorithm registration
shunkica Mar 5, 2026
41bab4a
fix: improve getCertFromKeyInfo docs and normalize thrown errors
shunkica Mar 5, 2026
920d0d4
Make tests pass
cjbarth Mar 5, 2026
1079bb9
Remove unused imports
cjbarth Mar 5, 2026
260850f
Lint
cjbarth Mar 5, 2026
b64e74e
Adjust some test names to better reflect what is being tested
cjbarth Mar 5, 2026
97b0b94
Improve test coverage and make tests match descriptions
cjbarth Mar 5, 2026
cd83d8e
Add some todos and some more test coverage
cjbarth Mar 5, 2026
ad260c2
Clean up some more tests
cjbarth Mar 5, 2026
04b411a
Fix tests
cjbarth Mar 6, 2026
f90f841
Require non-empty truststore for getCertFromKeyInfo; surface accepted…
shunkica May 15, 2026
4ab6377
Add XmlDSigVerifier.extractAndVerify for deferred-trust verification
shunkica May 15, 2026
95568a2
Document trust model and deferred-trust verification
shunkica May 15, 2026
eeb6e8c
Refactor attr namespace helpers to three-way branching
shunkica May 15, 2026
c258b31
Throw a clear error when ensureHasId hits empty idAttributes
shunkica May 15, 2026
dc6929a
Tighten verifier paths and dedupe security-options plumbing
shunkica May 15, 2026
c9a39c7
Pass the validated cert downstream, not the raw KeyInfo string
shunkica May 18, 2026
16520bc
Fix verifier state reuse and enforce key-confusion guards on all paths
shunkica Jul 14, 2026
34e739f
Reset per-signature state in loadSignature
shunkica Jul 14, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,36 @@ Note:

The xml-crypto api requires you to supply it separately the xml signature ("<Signature>...</Signature>", in loadSignature) and the signed xml (in checkSignature). The signed xml may or may not contain the signature in it, but you are still required to supply the signature separately.

### Secure Verification with XmlDSigVerifier (Recommended)

For a more secure and streamlined verification experience, use the `XmlDSigVerifier` class. It provides built-in checks for certificate expiration, truststore validation, and easier configuration.

```javascript
const { XmlDSigVerifier } = require("xml-crypto");
const fs = require("fs");

const xml = fs.readFileSync("signed.xml", "utf-8");
const publicCert = fs.readFileSync("client_public.pem", "utf-8");

const result = XmlDSigVerifier.verifySignature(xml, {
keySelector: { publicCert: publicCert },
});

if (result.success) {
console.log("Valid signature!");
console.log("Signed content:", result.signedReferences);
} else {
console.error("Invalid signature:", result.error);
}
```

The verifier exposes two trust modes:

- `verifySignature` — strict. When using `getCertFromKeyInfo`, a non-empty `truststore` is required; trust is direct only (cert pinning or single-hop CA, not full PKIX chain walking).
- `extractAndVerify` — deferred trust. Performs signature math against the embedded certificate and returns it as `untrustedCertificate` for the caller to validate out-of-band (XAdES-LTV, EU Trusted List, e-invoicing archival, etc.). Use only when trust will be established by an external authority.

For detailed usage instructions, see [XMLDSIG_VERIFIER.md](./XMLDSIG_VERIFIER.md).

### Caring for Implicit transform

If you fail to verify signed XML, then one possible cause is that there are some hidden implicit transforms(#).
Expand Down
Loading