Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,15 @@ The `enveloped-signature` transform removes only the `Signature` element being v
- `getCanonXml()` finds the loaded signature in the node's document the same way, and removes nothing
when the signature is not there.

### Documents with a DOCTYPE

`computeSignature()` and `checkSignature()` do not process a document type declaration. An entity
it declares is not expanded and a default attribute it declares is not added, though
[Canonical XML](https://www.w3.org/TR/xml-c14n#Terminology) requires both, so the canonical form is
not the one an implementation that processes the declaration computes. Signing or verifying a
document that has a DOCTYPE is deprecated and will throw in 7.0. Until then it prints a
`DeprecationWarning`.

### Malformed certificates

A certificate whose encapsulated data is not base64 is rejected rather than decoded as far as it
Expand Down
12 changes: 12 additions & 0 deletions src/signed-xml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,12 @@ const warnOriginalXmlWithIds = deprecate(
"XML_CRYPTO_GET_ORIGINAL_XML_WITH_IDS",
);

const warnDocumentTypeDeclaration = deprecate(
() => {},
"Signing or verifying a document that has a document type declaration (`<!DOCTYPE>`) is deprecated and will throw in version 7.0. The declaration is not processed, so an entity it declares is not expanded and a default attribute it declares is not added to what is signed or verified.",
"XML_CRYPTO_DOCUMENT_TYPE_DECLARATION",
);

const warnValidateElementAgainstReferences = deprecate(
() => {},
"`validateElementAgainstReferences()` is deprecated and will be removed in a future version. After `checkSignature()` succeeds, use the XML that `getSignedReferences()` returns instead of nodes from the original document.",
Expand Down Expand Up @@ -365,6 +371,9 @@ export class SignedXml {
this.signedXml = xml;

const doc = new xmldom.DOMParser().parseFromString(xml);
if (doc.doctype != null) {
warnDocumentTypeDeclaration();
}

// Reset the references as only references from our re-parsed signedInfo node can be trusted
this.references = [];
Expand Down Expand Up @@ -1034,6 +1043,9 @@ export class SignedXml {
}

const doc = new xmldom.DOMParser().parseFromString(xml);
if (doc.doctype != null) {
warnDocumentTypeDeclaration();
}
let xmlNsAttr = "xmlns";
const signatureAttrs: string[] = [];
let currentPrefix: string;
Expand Down
Loading