diff --git a/lib/signed-xml.js b/lib/signed-xml.js index 8fbb18da..18e3d369 100644 --- a/lib/signed-xml.js +++ b/lib/signed-xml.js @@ -200,8 +200,10 @@ function SignedXml(idMode, options) { if (this.options.idAttribute) this.idAttributes.splice(0, 0, this.options.idAttribute); } +//For now we are mapping WithComments canonicalization to ExclusiveCanonicalization SignedXml.CanonicalizationAlgorithms = { 'http://www.w3.org/2001/10/xml-exc-c14n#': ExclusiveCanonicalization, + 'http://www.w3.org/2001/10/xml-exc-c14n#WithComments': ExclusiveCanonicalization, 'http://www.w3.org/2000/09/xmldsig#enveloped-signature': EnvelopedSignature } diff --git a/test/saml-response-test.js b/test/saml-response-test.js index 1891f20f..efd8ff78 100644 --- a/test/saml-response-test.js +++ b/test/saml-response-test.js @@ -14,6 +14,18 @@ exports['test validating SAML response'] = function (test) { test.done(); }; +exports['test validating SAML response with WithComments Canonicalization'] = function (test) { + var xml = fs.readFileSync('./test/static/saml_external_canonicalization_with_comments.xml', 'utf-8'); + var doc = new xmldom.DOMParser().parseFromString(xml); + var signature = crypto.xpath(doc, "/*/*[local-name(.)='Signature' and namespace-uri(.)='http://www.w3.org/2000/09/xmldsig#']")[0]; + var sig = new crypto.SignedXml(); + sig.keyInfoProvider = new crypto.FileKeyInfo("./test/static/WithComments-Signing-Cert.pem"); + sig.loadSignature(signature.toString()); + var result = sig.checkSignature(xml); + test.equal(result, true); + test.done(); +}; + exports['test validating SAML response where a namespace is defined outside the signed element'] = function (test) { var xml = fs.readFileSync('./test/static/saml_external_ns.xml', 'utf-8'); var doc = new xmldom.DOMParser().parseFromString(xml); diff --git a/test/static/WithComments-Signing-Cert.pem b/test/static/WithComments-Signing-Cert.pem new file mode 100644 index 00000000..1e8bc310 --- /dev/null +++ b/test/static/WithComments-Signing-Cert.pem @@ -0,0 +1,17 @@ +-----BEGIN CERTIFICATE----- +MIICoDCCAYigAwIBAgIGHg9wUUEQMA0GCSqGSIb3DQEBCwUAMBQxEjAQBgNVBAMM +CUNsb3VkR2F0ZTAeFw0xNDA3MjIwODExMjNaFw0yNDA3MjIwODExMjNaMA4xDDAK +BgNVBAMMA2N5MjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKtVuICl +FLEs3sjYAWvq5UcI7LJt6AY47axylNsAGPgYFtd3W6q/lXXyG01P4vsh6GF4iZou +PrNBFa6fFom9xJ9f5b3ge/LgBcj9wbc0tsUhs+RXOaHiKUrlIS3ieUjyq3KWUvsD +eEMrTiItzn7+RqnZ6V5wjFg2Chqzc2+133Xp1S9S7J2GHAL/BwdF/2iIzFW5Fk7t +XQ0p5vtWvRdzGObY08ivl8s5+DQYaRU8xjrXvzUqQYAzj5Tns+kqjphMJ2B9/TRV +tVQ4IPa8agzjidGXlveIFB3F0QuoginSmGPaTb9nzVipSk5FEg1nscCvjDO7uBGc +huIHx8KWz8NJ0vcCAwEAATANBgkqhkiG9w0BAQsFAAOCAQEAdo/PpgdHCbSaxliy +YDrvk2f09I/6sv7asj5/ChCQX/1ZeD1vQfX9e8GX6HHkUbv/lzdTk02zM5v/nQCU +enPaM/29lpsp8+CSxj7+FR6FB5IIIDkMxUPSyyaXjAaF5AhtH9XBw2RWzdCmgbfz +ukXYu58DGAsAGs+fzxZnctgxe0l7AjX/sgeIVfSrlbIWDuY+pXraoL7fFsyBG3R4 +qbldSUoLI6brspEs2j9uf+lG6Ss9ucviMKK0auNP8eXsOa85nXUt14a6d8wScEoF +R0u/G2zb+CgQx8sQRl63vOk9krlxymblrR6Uv+F1KoFb9F8Sfg3NeCIa3hYOd66/ +yKN1Tg== +-----END CERTIFICATE----- \ No newline at end of file diff --git a/test/static/saml_external_canonicalization_with_comments.xml b/test/static/saml_external_canonicalization_with_comments.xml new file mode 100644 index 00000000..9ddd4bb3 --- /dev/null +++ b/test/static/saml_external_canonicalization_with_comments.xml @@ -0,0 +1,5 @@ +https://ng-qa.isr.co.jp/sso/cy2/66EcBXuIS5btQTYJINZiDfynHOc=eIb5bM1NwrQdlImifS8T3qA0bRpqTAWr1y7JadC1KON/xrB3Gn1TIa5AZBgiAujgqrQt/NBbC4cF50n4p3Y/qs0eValKxhnfgOA5uWyyQXF1hZjovWvgS3PH9JAUPHx5klQ16F6Mf6vk1mUJ36mFQWbjAo6NS2AWSxciv06RWaiimBwoK4P0XqeyqfBxjplE/v4s55ZwGofaY6X5NibZCyHfnfQrIim48fZeAa3LJ+55dcy8LmT4DXqlBDjssmdbTP/UUrXoXMLVfLD4Fb+tp83Tf8CGAzIyq65q0ADyd7mJBCHUthFny9lDNYRU8XhZEIosJtiLzWiul8Pm+JcoVg==q1W4gKUUsSzeyNgBa+rlRwjssm3oBjjtrHKU2wAY+BgW13dbqr+VdfIbTU/i+yHoYXiJmi4+s0EV +rp8Wib3En1/lveB78uAFyP3BtzS2xSGz5Fc5oeIpSuUhLeJ5SPKrcpZS+wN4QytOIi3Ofv5Gqdnp +XnCMWDYKGrNzb7XfdenVL1LsnYYcAv8HB0X/aIjMVbkWTu1dDSnm+1a9F3MY5tjTyK+Xyzn4NBhp +FTzGOte/NSpBgDOPlOez6SqOmEwnYH39NFW1VDgg9rxqDOOJ0ZeW94gUHcXRC6iCKdKYY9pNv2fN +WKlKTkUSDWexwK+MM7u4EZyG4gfHwpbPw0nS9w==AQABhttps://ng-qa.isr.co.jp/sso/cy2/kaneko@isr.co.jpurn:auth0:optimizely:recruitjobs06032015urn:oasis:names:tc:SAML:2.0:ac:classes:Password \ No newline at end of file