{"action":"created","issue":{"url":"https://api.github.com/repos/jberger/Mojo-SAML/issues/2","repository_url":"https://api.github.com/repos/jberger/Mojo-SAML","labels_url":"https://api.github.com/repos/jberger/Mojo-SAML/issues/2/labels{/name}","comments_url":"https://api.github.com/repos/jberger/Mojo-SAML/issues/2/comments","events_url":"https://api.github.com/repos/jberger/Mojo-SAML/issues/2/events","html_url":"https://github.com/jberger/Mojo-SAML/issues/2","id":343261495,"node_id":"MDU6SXNzdWUzNDMyNjE0OTU=","number":2,"title":"XMLSig fails when namespaces are declared in the root","user":{"login":"alexrj","id":594957,"node_id":"MDQ6VXNlcjU5NDk1Nw==","avatar_url":"https://avatars2.githubusercontent.com/u/594957?v=4","gravatar_id":"","url":"https://api.github.com/users/alexrj","html_url":"https://github.com/alexrj","followers_url":"https://api.github.com/users/alexrj/followers","following_url":"https://api.github.com/users/alexrj/following{/other_user}","gists_url":"https://api.github.com/users/alexrj/gists{/gist_id}","starred_url":"https://api.github.com/users/alexrj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexrj/subscriptions","organizations_url":"https://api.github.com/users/alexrj/orgs","repos_url":"https://api.github.com/users/alexrj/repos","events_url":"https://api.github.com/users/alexrj/events{/privacy}","received_events_url":"https://api.github.com/users/alexrj/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2018-07-20T22:08:59Z","updated_at":"2018-07-22T08:30:12Z","closed_at":null,"author_association":"NONE","body":"When verifying the signature on the following XML file, Mojo::XMLSig fails to parse it correctly.\r\n\r\n```xml\r\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<ns0:Response xmlns:ns0=\"urn:oasis:names:tc:SAML:2.0:protocol\" xmlns:ns1=\"urn:oasis:names:tc:SAML:2.0:assertion\" xmlns:ns2=\"http://www.w3.org/2000/09/xmldsig#\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" Destination=\"http://localhost:3000/spid-sso\" ID=\"id-12gGoICXbISlj3NOp\" InResponseTo=\"68852c0bccc85abcc0225654de76c5ee\" IssueInstant=\"2018-07-15T19:34:17Z\" Version=\"2.0\">\r\n\t<ns1:Issuer Format=\"urn:oasis:names:tc:SAML:2.0:nameid-format:entity\">\r\n\t\thttp://localhost:8088\r\n\t</ns1:Issuer>\r\n\t<ns0:Status>\r\n\t\t<ns0:StatusCode Value=\"urn:oasis:names:tc:SAML:2.0:status:Success\" />\r\n\t</ns0:Status>\r\n\t<ns1:Assertion ID=\"id-3cF3VhiK4ZCALk5S3\" IssueInstant=\"2018-07-15T19:34:17Z\" Version=\"2.0\">\r\n\t\t<ns1:Issuer Format=\"urn:oasis:names:tc:SAML:2.0:nameid-format:entity\">\r\n\t\t\thttp://localhost:8088\r\n\t\t</ns1:Issuer>\r\n\t\t<ns2:Signature Id=\"Signature2\">\r\n\t\t\t<ns2:SignedInfo>\r\n\t\t\t\t<ns2:CanonicalizationMethod Algorithm=\"http://www.w3.org/2001/10/xml-exc-c14n#\" /><ns2:SignatureMethod Algorithm=\"http://www.w3.org/2001/04/xmldsig-more#rsa-sha512\" />\r\n\t\t\t\t<ns2:Reference URI=\"#id-3cF3VhiK4ZCALk5S3\">\r\n\t\t\t\t\t<ns2:Transforms>\r\n\t\t\t\t\t\t<ns2:Transform Algorithm=\"http://www.w3.org/2000/09/xmldsig#enveloped-signature\" /><ns2:Transform Algorithm=\"http://www.w3.org/2001/10/xml-exc-c14n#\" />\r\n\t\t\t\t\t</ns2:Transforms>\r\n\t\t\t\t\t<ns2:DigestMethod Algorithm=\"http://www.w3.org/2001/04/xmlenc#sha512\" />\r\n\t\t\t\t\t<ns2:DigestValue>\r\n\t\t\t\t\t\tArbbJhtF4hFgjYwSlKDoYeKBcHI7If9SR3vn/68Q237p3vcFecUUD9pmDTi+O14n 9c7vCcjXSqPrx09hcnKdNg==\r\n\t\t\t\t\t</ns2:DigestValue>\r\n\t\t\t\t</ns2:Reference>\r\n\t\t\t</ns2:SignedInfo>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3DQEBCwUAA4IBAQBw4mfH+WtR/etTVWK1Jy9DXWxAazFViQcVBualTuleRSHZjCv/nyv4YbyFlTNarDI+LF+iG2rCABxgY40L6FpN9Gnsa5wijuKs0E6ZAvJ/rYfrYkE8wd0y8Z23VeoXD/m8OhwcysMtyM10GxZUtEBnpXDAhAFFDyAACfxAQy+/5u1u5dI0189AFk2EcqcSuA9pQWbzhswlQaSQFBU1nabIU2SwDPfHMwLFVrJdH09RuMSKM4IBNzCiLj5KgqepdFO3+8e0ewiwo8imhTYaTDR3ZXQaTNQt99fhT/LOMUcCR4hH14Cn72X7xTPK7hTz4p1D3uXfKT/o1qiql2PAjfl8\r\n\t\t\t\t\t</ns2:X509Certificate>\r\n\t\t\t\t</ns2:X509Data>\r\n\t\t\t</ns2:KeyInfo>\r\n\t\t</ns2:Signature>\r\n\t\t<ns1:Subject>\r\n\t\t\t<ns1:NameID Format=\"urn:oasis:names:tc:SAML:2.0:nameid-format:transient\" NameQualifier=\"http://localhost:8088\" SPNameQualifier=\"https://localhost/\">\r\n\t\t\t\t856e0b9685205cef8f79c9e8d92b1507dc47c710d840a44816b769f9d5c94a5d\r\n\t\t\t</ns1:NameID>\r\n\t\t\t<ns1:SubjectConfirmation Method=\"urn:oasis:names:tc:SAML:2.0:cm:bearer\">\r\n\t\t\t\t<ns1:SubjectConfirmationData InResponseTo=\"68852c0bccc85abcc0225654de76c5ee\" NotOnOrAfter=\"2018-07-15T20:34:17Z\" Recipient=\"http://localhost:3000/spid-sso\" />\r\n\t\t\t</ns1:SubjectConfirmation>\r\n\t\t</ns1:Subject>\r\n\t\t<ns1:Conditions NotBefore=\"2018-07-15T19:34:17Z\" NotOnOrAfter=\"2018-07-15T20:34:17Z\">\r\n\t\t\t<ns1:AudienceRestriction>\r\n\t\t\t\t<ns1:Audience>\r\n\t\t\t\t\thttps://localhost/\r\n\t\t\t\t</ns1:Audience>\r\n\t\t\t</ns1:AudienceRestriction>\r\n\t\t</ns1:Conditions>\r\n\t\t<ns1:AuthnStatement AuthnInstant=\"2018-07-15T19:34:17Z\" SessionIndex=\"id-qs6hTEHWz7aU0V7Da\">\r\n\t\t\t<ns1:AuthnContext>\r\n\t\t\t\t<ns1:AuthnContextClassRef>\r\n\t\t\t\t\thttps://www.spid.gov.it/SpidL1\r\n\t\t\t\t</ns1:AuthnContextClassRef>\r\n\t\t\t\t<ns1:AuthenticatingAuthority>\r\n\t\t\t\t\thttps://www.spid.gov.it/SpidL1\r\n\t\t\t\t</ns1:AuthenticatingAuthority>\r\n\t\t\t</ns1:AuthnContext>\r\n\t\t</ns1:AuthnStatement>\r\n\t\t<ns1:AttributeStatement>\r\n\t\t\t<ns1:Attribute FriendlyName=\"name\" Name=\"urn:mace:dir:attribute-def:name\" NameFormat=\"urn:oasis:names:tc:SAML:2.0:attrname-format:basic\">\r\n\t\t\t\t<ns1:AttributeValue xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xsi:type=\"xs:string\">\r\n\t\t\t\t\tMario\r\n\t\t\t\t</ns1:AttributeValue>\r\n\t\t\t</ns1:Attribute>\r\n\t\t\t<ns1:Attribute Name=\"fiscalNumber\" NameFormat=\"urn:oasis:names:tc:SAML:2.0:attrname-format:uri\">\r\n\t\t\t\t<ns1:AttributeValue xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xsi:type=\"xs:string\">\r\n\t\t\t\t\tRSOMRO70M20H501X\r\n\t\t\t\t</ns1:AttributeValue>\r\n\t\t\t</ns1:Attribute>\r\n\t\t\t<ns1:Attribute Name=\"familyName\" NameFormat=\"urn:oasis:names:tc:SAML:2.0:attrname-format:uri\">\r\n\t\t\t\t<ns1:AttributeValue xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xsi:type=\"xs:string\">\r\n\t\t\t\t\tRossi\r\n\t\t\t\t</ns1:AttributeValue>\r\n\t\t\t</ns1:Attribute>\r\n\t\t\t<ns1:Attribute Name=\"dateOfBirth\" NameFormat=\"urn:oasis:names:tc:SAML:2.0:attrname-format:uri\">\r\n\t\t\t\t<ns1:AttributeValue xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xsi:type=\"xs:string\">\r\n\t\t\t\t\t1970-01-01\r\n\t\t\t\t</ns1:AttributeValue>\r\n\t\t\t</ns1:Attribute>\r\n\t\t</ns1:AttributeStatement>\r\n\t</ns1:Assertion>\r\n</ns0:Response>\r\n```\r\n\r\nThis is the output:\r\n\r\n```\r\nnamespace error : Namespace prefix ns1 on Assertion is not defined\r\ntion ID=\"id-3cF3VhiK4ZCALk5S3\" IssueInstant=\"2018-07-15T19:34:17Z\" Version=\"2.0\"\r\n                                                                               ^\r\nnamespace error : Namespace prefix ns1 on Issuer is not defined\r\n\t\t<ns1:Issuer Format=\"urn:oasis:names:tc:SAML:2.0:nameid-format:entity\">\r\n\t\t                                                                     ^\r\nnamespace error : Namespace prefix ns1 on Subject is not defined\r\n\t\t<ns1:Subject>\r\n\t\t            ^\r\nnamespace error : Namespace prefix ns1 on NameID is not defined\r\nient\" NameQualifier=\"http://localhost:8088\" SPNameQualifier=\"https://localhost/\"\r\n                                                                               ^\r\nnamespace error : Namespace prefix ns1 on SubjectConfirmation is not defined\r\n\t\t\t<ns1:SubjectConfirmation Method=\"urn:oasis:names:tc:SAML:2.0:cm:bearer\">\r\n\t\t\t                                                                       ^\r\nnamespace error : Namespace prefix ns1 on SubjectConfirmationData is not defined\r\n NotOnOrAfter=\"2018-07-15T20:34:17Z\" Recipient=\"http://localhost:3000/spid-sso\"\r\n                                                                               ^\r\nnamespace error : Namespace prefix ns1 on Conditions is not defined\r\n:Conditions NotBefore=\"2018-07-15T19:34:17Z\" NotOnOrAfter=\"2018-07-15T20:34:17Z\"\r\n                                                                               ^\r\nnamespace error : Namespace prefix ns1 on AudienceRestriction is not defined\r\n\t\t\t<ns1:AudienceRestriction>\r\n\t\t\t                        ^\r\nnamespace error : Namespace prefix ns1 on Audience is not defined\r\n\t\t\t\t<ns1:Audience>\r\n\t\t\t\t             ^\r\nnamespace error : Namespace prefix ns1 on AuthnStatement is not defined\r\ntatement AuthnInstant=\"2018-07-15T19:34:17Z\" SessionIndex=\"id-qs6hTEHWz7aU0V7Da\"\r\n                                                                               ^\r\nnamespace error : Namespace prefix ns1 on AuthnContext is not defined\r\n\t\t\t<ns1:AuthnContext>\r\n\t\t\t                 ^\r\nnamespace error : Namespace prefix ns1 on AuthnContextClassRef is not defined\r\n\t\t\t\t<ns1:AuthnContextClassRef>\r\n\t\t\t\t                         ^\r\nnamespace error : Namespace prefix ns1 on AuthenticatingAuthority is not defined\r\n\t\t\t\t<ns1:AuthenticatingAuthority>\r\n\t\t\t\t                            ^\r\nnamespace error : Namespace prefix ns1 on AttributeStatement is not defined\r\n\t\t<ns1:AttributeStatement>\r\n\t\t                       ^\r\nnamespace error : Namespace prefix ns1 on Attribute is not defined\r\ntribute-def:name\" NameFormat=\"urn:oasis:names:tc:SAML:2.0:attrname-format:basic\"\r\n                                                                               ^\r\nnamespace error : Namespace prefix xsi for type on AttributeValue is not defined\r\n:AttributeValue xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xsi:type=\"xs:string\"\r\n                                                                               ^\r\nnamespace error : Namespace prefix ns1 on AttributeValue is not defined\r\n:AttributeValue xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xsi:type=\"xs:string\"\r\n                                                                               ^\r\nnamespace error : Namespace prefix ns1 on Attribute is not defined\r\nName=\"fiscalNumber\" NameFormat=\"urn:oasis:names:tc:SAML:2.0:attrname-format:uri\"\r\n                                                                               ^\r\nnamespace error : Namespace prefix xsi for type on AttributeValue is not defined\r\n:AttributeValue xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xsi:type=\"xs:string\"\r\n                                                                               ^\r\nnamespace error : Namespace prefix ns1 on AttributeValue is not defined\r\n:AttributeValue xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xsi:type=\"xs:string\"\r\n                                                                               ^\r\nnamespace error : Namespace prefix ns1 on Attribute is not defined\r\ne Name=\"familyName\" NameFormat=\"urn:oasis:names:tc:SAML:2.0:attrname-format:uri\"\r\n                                                                               ^\r\nnamespace error : Namespace prefix xsi for type on AttributeValue is not defined\r\n:AttributeValue xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xsi:type=\"xs:string\"\r\n                                                                               ^\r\nnamespace error : Namespace prefix ns1 on AttributeValue is not defined\r\n:AttributeValue xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xsi:type=\"xs:string\"\r\n                                                                               ^\r\nnamespace error : Namespace prefix ns1 on Attribute is not defined\r\n Name=\"dateOfBirth\" NameFormat=\"urn:oasis:names:tc:SAML:2.0:attrname-format:uri\"\r\n                                                                               ^\r\nnamespace error : Namespace prefix xsi for type on AttributeValue is not defined\r\n:AttributeValue xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xsi:type=\"xs:string\"\r\n                                                                               ^\r\nnamespace error : Namespace prefix ns1 on AttributeValue is not defined\r\n:AttributeValue xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xsi:type=\"xs:string\"\r\n                                                                               ^\r\nExisting digest 'ArbbJhtF4hFgjYwSlKDoYeKBcHI7If9SR3vn/68Q237p3vcFecUUD9pmDTi+O14n 9c7vCcjXSqPrx09hcnKdNg==' does not equal calculated value '1hr5tjqX6TKzsac5lKhemUHkk0NgXDwaspOCIAbNP9u/STLl0ol9UzbOq+by7mYwFiY6p4aIbjyosyl/rZ1k7g==' at /Library/Perl/5.18/Mojo/Collection.pm line 25.\r\n```\r\n\r\nThe issue is caused by this XML file having all the namespaces declared in the root element."},"comment":{"url":"https://api.github.com/repos/jberger/Mojo-SAML/issues/comments/406849962","html_url":"https://github.com/jberger/Mojo-SAML/issues/2#issuecomment-406849962","issue_url":"https://api.github.com/repos/jberger/Mojo-SAML/issues/2","id":406849962,"node_id":"MDEyOklzc3VlQ29tbWVudDQwNjg0OTk2Mg==","user":{"login":"alexrj","id":594957,"node_id":"MDQ6VXNlcjU5NDk1Nw==","avatar_url":"https://avatars2.githubusercontent.com/u/594957?v=4","gravatar_id":"","url":"https://api.github.com/users/alexrj","html_url":"https://github.com/alexrj","followers_url":"https://api.github.com/users/alexrj/followers","following_url":"https://api.github.com/users/alexrj/following{/other_user}","gists_url":"https://api.github.com/users/alexrj/gists{/gist_id}","starred_url":"https://api.github.com/users/alexrj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexrj/subscriptions","organizations_url":"https://api.github.com/users/alexrj/orgs","repos_url":"https://api.github.com/users/alexrj/repos","events_url":"https://api.github.com/users/alexrj/events{/privacy}","received_events_url":"https://api.github.com/users/alexrj/received_events","type":"User","site_admin":false},"created_at":"2018-07-22T08:30:12Z","updated_at":"2018-07-22T08:30:12Z","author_association":"NONE","body":"This is how it's done with libxml2: https://stackoverflow.com/questions/40626702/libxml2-output-namespace-declarations-in-non-root-elements"}}
{"actor":{"display_login":"alexrj"}}