Skip to content

Commit

Permalink
Set getCertFromKeyInfo to noop (#445)
Browse files Browse the repository at this point in the history
`getKeyInfoContent` was incorrectly set to `noop` instead of `getCertFromKeyInfo`
  • Loading branch information
cjbarth committed Jan 26, 2024
1 parent f8cbbb7 commit 2120172
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/signed-xml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ export class SignedXml {
}
this.implicitTransforms = implicitTransforms ?? this.implicitTransforms;
this.keyInfoAttributes = keyInfoAttributes ?? this.keyInfoAttributes;
this.getKeyInfoContent = getKeyInfoContent ?? SignedXml.noop;
this.getCertFromKeyInfo = getCertFromKeyInfo ?? this.getCertFromKeyInfo;
this.getKeyInfoContent = getKeyInfoContent ?? this.getKeyInfoContent;
this.getCertFromKeyInfo = getCertFromKeyInfo ?? SignedXml.noop;
this.CanonicalizationAlgorithms;
this.HashAlgorithms;
this.SignatureAlgorithms;
Expand Down
3 changes: 3 additions & 0 deletions test/document-tests.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ describe("Validated node references tests", function () {
const xml = fs.readFileSync("./test/static/valid_saml.xml", "utf-8");
const doc = new xmldom.DOMParser().parseFromString(xml);
const sig = new SignedXml();
sig.getCertFromKeyInfo = SignedXml.getCertFromKeyInfo;
sig.loadSignature(sig.findSignatures(doc)[0]);
const validSignature = sig.checkSignature(xml);
expect(validSignature).to.be.true;
Expand All @@ -73,6 +74,7 @@ describe("Validated node references tests", function () {
const xml = fs.readFileSync("./test/static/valid_saml.xml", "utf-8");
const doc = new xmldom.DOMParser().parseFromString(xml);
const sig = new SignedXml();
sig.getCertFromKeyInfo = SignedXml.getCertFromKeyInfo;
sig.loadSignature(sig.findSignatures(doc)[0]);
const validSignature = sig.checkSignature(xml);
expect(validSignature).to.be.true;
Expand All @@ -86,6 +88,7 @@ describe("Validated node references tests", function () {
const xml = fs.readFileSync("./test/static/valid_saml.xml", "utf-8");
const doc = new xmldom.DOMParser().parseFromString(xml);
const sig = new SignedXml();
sig.getCertFromKeyInfo = SignedXml.getCertFromKeyInfo;
sig.loadSignature(sig.findSignatures(doc)[0]);
const validSignature = sig.checkSignature(xml);
expect(validSignature).to.be.true;
Expand Down
1 change: 0 additions & 1 deletion test/key-info-tests.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ describe("KeyInfo tests", function () {
sig.publicCert = fs.readFileSync("./test/static/client_public.pem");
sig.canonicalizationAlgorithm = "http://www.w3.org/2001/10/xml-exc-c14n#";
sig.signatureAlgorithm = "http://www.w3.org/2000/09/xmldsig#rsa-sha1";
sig.getKeyInfoContent = SignedXml.getKeyInfoContent;
sig.computeSignature(xml);
const signedXml = sig.getSignedXml();
const doc = new xmldom.DOMParser().parseFromString(signedXml);
Expand Down
2 changes: 0 additions & 2 deletions test/signature-unit-tests.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,6 @@ describe("Signature unit tests", function () {
sig.signatureAlgorithm = "http://dummySignatureAlgorithm";
sig.canonicalizationAlgorithm = "http://DummyCanonicalization";
sig.privateKey = "";
sig.getKeyInfoContent = SignedXml.getKeyInfoContent;

sig.addReference({
xpath: "//*[local-name(.)='x']",
Expand Down Expand Up @@ -1237,7 +1236,6 @@ describe("Signature unit tests", function () {
sig.publicCert = pemBuffer;
sig.canonicalizationAlgorithm = "http://www.w3.org/2001/10/xml-exc-c14n#";
sig.signatureAlgorithm = "http://www.w3.org/2000/09/xmldsig#rsa-sha1";
sig.getKeyInfoContent = SignedXml.getKeyInfoContent;
sig.computeSignature(xml);
const signedXml = sig.getSignedXml();

Expand Down

0 comments on commit 2120172

Please sign in to comment.