Skip to content

Commit 2120172

Browse files
authored
Set getCertFromKeyInfo to noop (#445)
`getKeyInfoContent` was incorrectly set to `noop` instead of `getCertFromKeyInfo`
1 parent f8cbbb7 commit 2120172

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

src/signed-xml.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,8 @@ export class SignedXml {
149149
}
150150
this.implicitTransforms = implicitTransforms ?? this.implicitTransforms;
151151
this.keyInfoAttributes = keyInfoAttributes ?? this.keyInfoAttributes;
152-
this.getKeyInfoContent = getKeyInfoContent ?? SignedXml.noop;
153-
this.getCertFromKeyInfo = getCertFromKeyInfo ?? this.getCertFromKeyInfo;
152+
this.getKeyInfoContent = getKeyInfoContent ?? this.getKeyInfoContent;
153+
this.getCertFromKeyInfo = getCertFromKeyInfo ?? SignedXml.noop;
154154
this.CanonicalizationAlgorithms;
155155
this.HashAlgorithms;
156156
this.SignatureAlgorithms;

test/document-tests.spec.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ describe("Validated node references tests", function () {
4747
const xml = fs.readFileSync("./test/static/valid_saml.xml", "utf-8");
4848
const doc = new xmldom.DOMParser().parseFromString(xml);
4949
const sig = new SignedXml();
50+
sig.getCertFromKeyInfo = SignedXml.getCertFromKeyInfo;
5051
sig.loadSignature(sig.findSignatures(doc)[0]);
5152
const validSignature = sig.checkSignature(xml);
5253
expect(validSignature).to.be.true;
@@ -73,6 +74,7 @@ describe("Validated node references tests", function () {
7374
const xml = fs.readFileSync("./test/static/valid_saml.xml", "utf-8");
7475
const doc = new xmldom.DOMParser().parseFromString(xml);
7576
const sig = new SignedXml();
77+
sig.getCertFromKeyInfo = SignedXml.getCertFromKeyInfo;
7678
sig.loadSignature(sig.findSignatures(doc)[0]);
7779
const validSignature = sig.checkSignature(xml);
7880
expect(validSignature).to.be.true;
@@ -86,6 +88,7 @@ describe("Validated node references tests", function () {
8688
const xml = fs.readFileSync("./test/static/valid_saml.xml", "utf-8");
8789
const doc = new xmldom.DOMParser().parseFromString(xml);
8890
const sig = new SignedXml();
91+
sig.getCertFromKeyInfo = SignedXml.getCertFromKeyInfo;
8992
sig.loadSignature(sig.findSignatures(doc)[0]);
9093
const validSignature = sig.checkSignature(xml);
9194
expect(validSignature).to.be.true;

test/key-info-tests.spec.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ describe("KeyInfo tests", function () {
1313
sig.publicCert = fs.readFileSync("./test/static/client_public.pem");
1414
sig.canonicalizationAlgorithm = "http://www.w3.org/2001/10/xml-exc-c14n#";
1515
sig.signatureAlgorithm = "http://www.w3.org/2000/09/xmldsig#rsa-sha1";
16-
sig.getKeyInfoContent = SignedXml.getKeyInfoContent;
1716
sig.computeSignature(xml);
1817
const signedXml = sig.getSignedXml();
1918
const doc = new xmldom.DOMParser().parseFromString(signedXml);

test/signature-unit-tests.spec.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,6 @@ describe("Signature unit tests", function () {
534534
sig.signatureAlgorithm = "http://dummySignatureAlgorithm";
535535
sig.canonicalizationAlgorithm = "http://DummyCanonicalization";
536536
sig.privateKey = "";
537-
sig.getKeyInfoContent = SignedXml.getKeyInfoContent;
538537

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

0 commit comments

Comments
 (0)