{"action":"created","issue":{"url":"https://api.github.com/repos/ebeigarts/signer/issues/13","repository_url":"https://api.github.com/repos/ebeigarts/signer","labels_url":"https://api.github.com/repos/ebeigarts/signer/issues/13/labels{/name}","comments_url":"https://api.github.com/repos/ebeigarts/signer/issues/13/comments","events_url":"https://api.github.com/repos/ebeigarts/signer/issues/13/events","html_url":"https://github.com/ebeigarts/signer/issues/13","id":172014767,"number":13,"title":"Output ds:Signature instead of Signature","user":{"login":"xvonabur","id":616857,"avatar_url":"https://avatars.githubusercontent.com/u/616857?v=3","gravatar_id":"","url":"https://api.github.com/users/xvonabur","html_url":"https://github.com/xvonabur","followers_url":"https://api.github.com/users/xvonabur/followers","following_url":"https://api.github.com/users/xvonabur/following{/other_user}","gists_url":"https://api.github.com/users/xvonabur/gists{/gist_id}","starred_url":"https://api.github.com/users/xvonabur/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xvonabur/subscriptions","organizations_url":"https://api.github.com/users/xvonabur/orgs","repos_url":"https://api.github.com/users/xvonabur/repos","events_url":"https://api.github.com/users/xvonabur/events{/privacy}","received_events_url":"https://api.github.com/users/xvonabur/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/ebeigarts/signer/labels/needs%20feedback","name":"needs feedback","color":"afafaf"}],"state":"open","locked":false,"assignee":{"login":"Envek","id":264400,"avatar_url":"https://avatars.githubusercontent.com/u/264400?v=3","gravatar_id":"","url":"https://api.github.com/users/Envek","html_url":"https://github.com/Envek","followers_url":"https://api.github.com/users/Envek/followers","following_url":"https://api.github.com/users/Envek/following{/other_user}","gists_url":"https://api.github.com/users/Envek/gists{/gist_id}","starred_url":"https://api.github.com/users/Envek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Envek/subscriptions","organizations_url":"https://api.github.com/users/Envek/orgs","repos_url":"https://api.github.com/users/Envek/repos","events_url":"https://api.github.com/users/Envek/events{/privacy}","received_events_url":"https://api.github.com/users/Envek/received_events","type":"User","site_admin":false},"assignees":[{"login":"Envek","id":264400,"avatar_url":"https://avatars.githubusercontent.com/u/264400?v=3","gravatar_id":"","url":"https://api.github.com/users/Envek","html_url":"https://github.com/Envek","followers_url":"https://api.github.com/users/Envek/followers","following_url":"https://api.github.com/users/Envek/following{/other_user}","gists_url":"https://api.github.com/users/Envek/gists{/gist_id}","starred_url":"https://api.github.com/users/Envek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Envek/subscriptions","organizations_url":"https://api.github.com/users/Envek/orgs","repos_url":"https://api.github.com/users/Envek/repos","events_url":"https://api.github.com/users/Envek/events{/privacy}","received_events_url":"https://api.github.com/users/Envek/received_events","type":"User","site_admin":false}],"milestone":null,"comments":2,"created_at":"2016-08-18T22:21:13Z","updated_at":"2016-08-24T16:34:37Z","closed_at":null,"body":"Hi!\r\n\r\nI would like to customize output of signature elements and output it with ds namespace. But I failed. Here is my code:\r\n\r\n```ruby\r\nrequire 'openssl'\r\nrequire 'signer'\r\n\r\nclass MySigner\r\n  def initialize\r\n    @soap_envelope = File.open('./data/soap_envelope.xml') { |f| Nokogiri::XML(f) }\r\n  end\r\n\r\n  def sign(xml_to_sign)\r\n    signer = Signer.new(put_in_envelope(xml_to_sign))\r\n    signer.cert = OpenSSL::X509::Certificate.new(File.read(\"./data/cert.pem\"))\r\n    signer.private_key = OpenSSL::PKey.read(File.read(\"./data/key.pem\"), \"PASSWORD\")\r\n    signer.security_token_id = 'CertId'\r\n\r\n    namespaces = {\r\n      'soap' => 'http://schemas.xmlsoap.org/soap/envelope/',\r\n      'ds' => 'http://www.w3.org/2000/09/xmldsig#'\r\n    }\r\n\r\n    # Digest soap:Body tag\r\n    signer.document.xpath('//TransferMsg', namespaces).each do |node|\r\n      signer.digest!(node, id: 'body')\r\n    end\r\n\r\n    # Sign document itself\r\n    signer.sign!(security_token: true, enveloped: true)\r\n\r\n    signer.to_xml\r\n  end\r\n\r\n  def put_in_envelope(xml)\r\n    xml_object = Nokogiri::XML(xml)\r\n    valuable_data = xml_object.xpath('/TransferMsg').to_s\r\n    @soap_envelope.xpath('//soap:Body').children.first.add_next_sibling(valuable_data)\r\n    @soap_envelope\r\n  end\r\nend  \r\n```\r\n\r\nsoap_envelope.xml:\r\n\r\n```xml\r\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"\r\n                   xmlns:wsse=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\"\r\n                   xmlns:wsu=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\"\r\n                   xmlns:ds=\"http://www.w3.org/2000/09/xmldsig#\">\r\n  <soap:Header>\r\n    <wsse:Security soap:actor=\"http://smev.gosuslugi.ru/actors/smev\"\r\n                   xmlns:wsse=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\">\r\n    </wsse:Security>\r\n  </soap:Header>\r\n  <soap:Body wsu:Id=\"body\">\r\n  </soap:Body>\r\n</soap:Envelope>\r\n```\r\n\r\nxml_to_sign example:\r\n\r\n```xml\r\n<TransferMsg>\r\n   <DataToDigest>Super Important Data</DataToDigest>\r\n</TransferMsg>\r\n```\r\n\r\nActual output:\r\n```xml\r\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<soap:Envelope xmlns:ds=\"http://www.w3.org/2000/09/xmldsig#\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:wsse=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\" xmlns:wsu=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\">\r\n\t<soap:Header>\r\n\t\t<wsse:Security soap:actor=\"http://smev.gosuslugi.ru/actors/smev\" xmlns:wsse=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\">\r\n\t\t\t<wsse:BinarySecurityToken EncodingType=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary\" ValueType=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3\" wsu:Id=\"CertId\">MIIIRzCCB/agAwIBAgIKSchnBgAAAAGKvDAIBgYqhQMCAgMwggFOMRgwFgYFKoUDZAESDTEwMjc3MDcwMTM4MDYxGjAYBggqhQMDgQMBARIMMDA3NzA3MzE0MDI5MTwwOgYDVQQJDDPQkS7QodGD0YXQsNGA0LXQstGB0LrQuNC5INC/0LXRgCzQtDExLNGB0YLRgDEs0L7RhDYxIzAhBgkqhkiG9w0BCQEWFGUtbW9za3ZhQGUtbW9za3ZhLnJ1MQswCQYDVQQGEwJSVTEcMBoGA1UECAwTNzcg0LMuINCc0L7RgdC60LLQsDEVMBMGA1UEBwwM0JzQvtGB0LrQstCwMTUwMwYDVQQKDCzQntCQ0J4gItCt0LvQtd=</wsse:BinarySecurityToken>\r\n\t\t\t<Signature xmlns=\"http://www.w3.org/2000/09/xmldsig#\">\r\n\t\t\t\t<SignedInfo>\r\n\t\t\t\t\t<CanonicalizationMethod Algorithm=\"http://www.w3.org/2001/10/xml-exc-c14n#\"/>\r\n\t\t\t\t\t<SignatureMethod Algorithm=\"http://www.w3.org/2001/04/xmldsig-more#gostr34102001-gostr3411\"/>\r\n\t\t\t\t</SignedInfo>\r\n\t\t\t\t<SignatureValue>vnjz04yWa7DbRtC5vJAt/tsCR5m31i3e8FMxG2eOIo4DtsGhm1FgZ8wKLEEzvbYuolrosc2OKkFafqJinsTWsg==</SignatureValue>\r\n\t\t\t\t<KeyInfo>\r\n\t\t\t\t\t<wsse:SecurityTokenReference>\r\n\t\t\t\t\t\t<wsse:Reference URI=\"#CertId\" ValueType=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3\"/>\r\n\t\t\t\t\t</wsse:SecurityTokenReference>\r\n\t\t\t\t</KeyInfo>\r\n\t\t\t</Signature>\r\n\t\t</wsse:Security>\r\n\t</soap:Header>\r\n\t<soap:Body wsu:Id=\"body\">\r\n\t\t<soap:TransferMsg>\r\n\t\t\t<soap:DataToDigest>Super Important Data</soap:DataToDigest>\r\n\t\t</soap:TransferMsg>\r\n\t</soap:Body>\r\n</soap:Envelope>\r\n\r\n```\r\n\r\nExpected output:\r\n```xml\r\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<soap:Envelope xmlns:ds=\"http://www.w3.org/2000/09/xmldsig#\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:wsse=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\" xmlns:wsu=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\">\r\n\t<soap:Header>\r\n\t\t<wsse:Security soap:actor=\"http://smev.gosuslugi.ru/actors/smev\" xmlns:wsse=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\">\r\n\t\t\t<wsse:BinarySecurityToken EncodingType=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary\" ValueType=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3\" wsu:Id=\"CertId\">MIIIRzCCB/agAwIBAgIKSchnBgAAAAGKvDAIBgYqhQMCAgMwggFOMRgwFgYFKoUDZAESDTEwMjc3MDcwMTM4MDYxGjAYBggqhQMDgQMBARIMMDA3NzA3MzE0MDI5MTwwOgYDVQQJDDPQkS7QodGD0YXQsNGA0LXQstGB0LrQuNC5INC/0LXRgCzQtDExLNGB0YLRgDEs0L7RhDYxIzAhBgkqhkiG9w0BCQEWFGUtbW9za3ZhQGUtbW9za3ZhLnJ1MQswCQYDVQQGEwJSVTEcMBoGA1UECAwTNzcg0LMuINCc0L7RgdC60LLQsDEVMBMGA1UEBwwM0JzQvtGB0LrQstCwMTUwMwYDVQQKDCzQntCQ0J4gItCt0LvQtd=</wsse:BinarySecurityToken>\r\n\t\t\t<ds:Signature>\r\n\t\t\t\t<ds:SignedInfo>\r\n\t\t\t\t\t<ds:CanonicalizationMethod Algorithm=\"http://www.w3.org/2001/10/xml-exc-c14n#\"/>\r\n\t\t\t\t\t<ds:SignatureMethod Algorithm=\"http://www.w3.org/2001/04/xmldsig-more#gostr34102001-gostr3411\"/>\r\n\t\t\t\t</ds:SignedInfo>\r\n\t\t\t\t<ds:SignatureValue>vnjz04yWa7DbRtC5vJAt/tsCR5m31i3e8FMxG2eOIo4DtsGhm1FgZ8wKLEEzvbYuolrosc2OKkFafqJinsTWsg==</SignatureValue>\r\n\t\t\t\t<ds:KeyInfo>\r\n\t\t\t\t\t<wsse:SecurityTokenReference>\r\n\t\t\t\t\t\t<wsse:Reference URI=\"#CertId\" ValueType=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3\"/>\r\n\t\t\t\t\t</wsse:SecurityTokenReference>\r\n\t\t\t\t</ds:KeyInfo>\r\n\t\t\t</Signature>\r\n\t\t</wsse:Security>\r\n\t</soap:Header>\r\n\t<soap:Body wsu:Id=\"body\">\r\n\t\t<soap:TransferMsg>\r\n\t\t\t<soap:DataToDigest>Super Important Data</soap:DataToDigest>\r\n\t\t</soap:TransferMsg>\r\n\t</soap:Body>\r\n</soap:Envelope>\r\n```\r\n\r\nAm I missing something? "},"comment":{"url":"https://api.github.com/repos/ebeigarts/signer/issues/comments/242129027","html_url":"https://github.com/ebeigarts/signer/issues/13#issuecomment-242129027","issue_url":"https://api.github.com/repos/ebeigarts/signer/issues/13","id":242129027,"user":{"login":"xvonabur","id":616857,"avatar_url":"https://avatars.githubusercontent.com/u/616857?v=3","gravatar_id":"","url":"https://api.github.com/users/xvonabur","html_url":"https://github.com/xvonabur","followers_url":"https://api.github.com/users/xvonabur/followers","following_url":"https://api.github.com/users/xvonabur/following{/other_user}","gists_url":"https://api.github.com/users/xvonabur/gists{/gist_id}","starred_url":"https://api.github.com/users/xvonabur/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xvonabur/subscriptions","organizations_url":"https://api.github.com/users/xvonabur/orgs","repos_url":"https://api.github.com/users/xvonabur/repos","events_url":"https://api.github.com/users/xvonabur/events{/privacy}","received_events_url":"https://api.github.com/users/xvonabur/received_events","type":"User","site_admin":false},"created_at":"2016-08-24T16:34:37Z","updated_at":"2016-08-24T16:34:37Z","body":"@Envek, you are right, technically they are the same, but somehow the receiver doesn't like default namespace of this node and basically says mysterious \"Wrong signature\". After reading code of this gem I managed to solve the problem by manually adding the Signature nodes with prefix and sign it with this gem. Unfortunately,  I have no control over receiver code, so can't say why it works that way.\r\n\r\nYour PR is very welcome for me."}}
{"actor":{"display_login":"xvonabur"}}