signer 1.2.0 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YWY1OWFhM2YzMDYxMzBiNTE3MTVkNDZiYTg3NDQ4MmM3MzcyMzdhMg==
4
+ MGVmNjVlMGNlMjM5ZmIyMzczYWIzNzRmNWYzOWRlZTA2NzFmMWZiOA==
5
5
  data.tar.gz: !binary |-
6
- NDI0MWQxNWZkYWI4NmE3YmQ2NzNlMTNiM2Q0OWY5Mzk5M2QyZGU5Mw==
6
+ ZDZjYWFiNmE2ODU5MGM4YjUxM2NjMzYyOTBmODBhZWQxYWJkYTFlNw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZDE0MDRmMGRiMWE4ZjQ5ODUxMjc2M2QwNjMxMTg0NzRlMzNiMGM1YTNmOTk3
10
- YzQ1Y2YyMmRmZGI2MThlM2Q5ODk2NjJiOTc0NDBkYjE2ZWZkYzk4MDRhZTc1
11
- OTdhODFhZTU4ZjkxYTA4ZGNlZjIwZDA5OWRjZDA5Nzc1ZTdmMWU=
9
+ MzQ3NjE2NTgxZGFjNGI5NmE2NjAxZWQ0MjNhMDY1YjAzZWNlOGY2YmM1YzNl
10
+ ZDNhYjEwZmQwYzYzYjc3NDA5OGRmM2MzYjgwZWFiYTQzYjllODNmNTllNjBk
11
+ ZWI4MmIwNWE0ODg1OGRlNzk5NmUxYjNmODJlMjIxN2Y3ZDAzNTM=
12
12
  data.tar.gz: !binary |-
13
- YzUwNDQ5MzljOTA1ZThlZTliMTNmZjljYTJlYmFjZDRhMDk1YWMzZDJjMTNl
14
- OTY1YmFmMzNkMzNmNWIwNTg2YWY2Njk1ZjEwMGMzYTVjZGRlM2U5ZWE0YWYx
15
- Mzc1MzE3MTI1YjQ2MzEzYWQ1OWE3MGIyMDU5YTI5MzgzMTlmM2U=
13
+ OTkzZWFiN2I4YmNiN2QyOWQ2N2E1MTZkMmQ0ODgwMGZhMjEzZTg4YzgzMzk4
14
+ NTJmNGY3ZWMzZTUzYzNjZWUzZmI2NTA0YWExM2EzZjY5ODEwY2ZhNGQ3NDRm
15
+ ZmI3ZWZmNTFlYWMyZjM3YjNlY2UwOTJiNDE5YzQ4N2Y0MWRiODI=
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 1.2.1 (2014-05-14)
2
+
3
+ - Fix canonicalization: should be without comments (#2, @Envek)
4
+
1
5
  ## 1.2.0 (2014-05-06)
2
6
 
3
7
  - Id and attribute namespace preserving when digesting the nodes (#1, @Envek)
data/lib/signer.rb CHANGED
@@ -28,7 +28,7 @@ class Signer
28
28
  end
29
29
 
30
30
  def canonicalize(node = document)
31
- node.canonicalize(Nokogiri::XML::XML_C14N_EXCLUSIVE_1_0)
31
+ node.canonicalize(Nokogiri::XML::XML_C14N_EXCLUSIVE_1_0, nil, nil) # The last argument should be exactly +nil+ to remove comments from result
32
32
  end
33
33
 
34
34
  # <Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
@@ -1,3 +1,3 @@
1
1
  class Signer
2
- VERSION = "1.2.0"
2
+ VERSION = "1.2.1"
3
3
  end
@@ -0,0 +1,22 @@
1
+ <?xml version="1.0"?>
2
+ <s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
3
+ <s:Header>
4
+ <a:Action s:mustUnderstand="1">http://tempuri.org/IDocumentService/SearchDocuments</a:Action>
5
+ <a:MessageID>urn:uuid:30db5d4f-ab84-46be-907c-be690a92979b</a:MessageID>
6
+ <To xmlns="http://www.w3.org/2005/08/addressing" xmlns:a="http://www.w3.org/2003/05/soap-envelope" a:mustUnderstand="1">http://tempuri.org/PublicServices/Test/1.0.12/PublicServices/DocumentService.svc</To>
7
+ <o:Security xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" s:mustUnderstand="1">
8
+ <u:Timestamp>
9
+ <u:Created>2012-05-02T18:17:14.467Z</u:Created>
10
+ <u:Expires>2012-05-02T18:22:14.467Z</u:Expires>
11
+ </u:Timestamp>
12
+ </o:Security>
13
+ </s:Header>
14
+ <s:Body>
15
+ <SearchDocuments xmlns="http://tempuri.org/">
16
+ <searchCriteria xmlns:b="http://schemas.datacontract.org/2004/07/BusinessLogic.Data.Documents.Integration" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
17
+ <!-- This comment shouldn't affect digest value for digested node -->
18
+ <b:RegistrationNo>1</b:RegistrationNo>
19
+ </searchCriteria>
20
+ </SearchDocuments>
21
+ </s:Body>
22
+ </s:Envelope>
@@ -0,0 +1,38 @@
1
+ <?xml version="1.0"?>
2
+ <s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing"
3
+ xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
4
+ <s:Header>
5
+ <a:Action s:mustUnderstand="1">http://tempuri.org/IDocumentService/SearchDocuments</a:Action>
6
+ <a:MessageID>urn:uuid:30db5d4f-ab84-46be-907c-be690a92979b</a:MessageID>
7
+ <To xmlns="http://www.w3.org/2005/08/addressing" xmlns:a="http://www.w3.org/2003/05/soap-envelope" a:mustUnderstand="1">http://tempuri.org/PublicServices/Test/1.0.12/PublicServices/DocumentService.svc</To>
8
+ <o:Security xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
9
+ s:mustUnderstand="1">
10
+ <u:Timestamp>
11
+ <u:Created>2012-05-02T18:17:14.467Z</u:Created>
12
+ <u:Expires>2012-05-02T18:22:14.467Z</u:Expires>
13
+ </u:Timestamp>
14
+ <Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
15
+ <SignedInfo>
16
+ <CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
17
+ <SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>
18
+ <Reference URI="#_f7a662fdba7cdb44426d7447f06adf0f11707eeb">
19
+ <Transforms>
20
+ <Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
21
+ </Transforms>
22
+ <DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
23
+ <DigestValue>iqiXdxdsix9HMz4rEBEo/sYazDU=</DigestValue>
24
+ </Reference>
25
+ </SignedInfo>
26
+ <SignatureValue>XOMmCzcg7Un+BpWIP5WpAAeT1Sq2B+WZ8eM4MiDR1bhIFV8aPScAXX/cB3Esa88JcBltsiBlZTdq1hCQ8GKrLEvWTFMhkSCQrkAR+3eCUR894UzPrWTr0jYA7RZaVaw+XODf7ICbYIhLs7n50cPyFrslKVOjh6EKlCq1ZV5XFYE=</SignatureValue>
27
+ </Signature>
28
+ </o:Security>
29
+ </s:Header>
30
+ <s:Body u:Id="_f7a662fdba7cdb44426d7447f06adf0f11707eeb">
31
+ <SearchDocuments xmlns="http://tempuri.org/">
32
+ <searchCriteria xmlns:b="http://schemas.datacontract.org/2004/07/BusinessLogic.Data.Documents.Integration" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
33
+ <!-- This comment shouldn't affect digest value for digested node -->
34
+ <b:RegistrationNo>1</b:RegistrationNo>
35
+ </searchCriteria>
36
+ </SearchDocuments>
37
+ </s:Body>
38
+ </s:Envelope>
data/spec/signer_spec.rb CHANGED
@@ -30,6 +30,23 @@ describe Signer do
30
30
  signer.to_xml.should == Nokogiri::XML(File.read(output_xml_file), &:noblanks).to_xml(:save_with => 0)
31
31
  end
32
32
 
33
+ it "should correctly canonicalize digested nodes (shouldn't account comments)" do
34
+ input_xml_file = File.join(File.dirname(__FILE__), 'fixtures', 'input_3_c14n_comments.xml')
35
+ cert_file = File.join(File.dirname(__FILE__), 'fixtures', 'cert.pem')
36
+ private_key_file = File.join(File.dirname(__FILE__), 'fixtures', 'key.pem')
37
+
38
+ signer = Signer.new(File.read(input_xml_file))
39
+ signer.cert = OpenSSL::X509::Certificate.new(File.read(cert_file))
40
+ signer.private_key = OpenSSL::PKey::RSA.new(File.read(private_key_file), "test")
41
+
42
+ signer.digest!(signer.document.at_xpath('//soap:Body', { 'soap' => 'http://www.w3.org/2003/05/soap-envelope'}))
43
+ signer.sign!
44
+
45
+ output_xml_file = File.join(File.dirname(__FILE__), 'fixtures', 'output_3_c14n_comments.xml')
46
+
47
+ signer.to_xml.should == Nokogiri::XML(File.read(output_xml_file), &:noblanks).to_xml(:save_with => 0)
48
+ end
49
+
33
50
  it "should sign simple XML" do
34
51
  input_xml_file = File.join(File.dirname(__FILE__), 'fixtures', 'input_2.xml')
35
52
  cert_file = File.join(File.dirname(__FILE__), 'fixtures', 'cert.pem')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: signer
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Edgars Beigarts
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-06 00:00:00.000000000 Z
11
+ date: 2014-05-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  version_requirements: !ruby/object:Gem::Requirement
@@ -67,9 +67,11 @@ files:
67
67
  - spec/fixtures/cert.pem
68
68
  - spec/fixtures/input_1.xml
69
69
  - spec/fixtures/input_2.xml
70
+ - spec/fixtures/input_3_c14n_comments.xml
70
71
  - spec/fixtures/key.pem
71
72
  - spec/fixtures/output_1.xml
72
73
  - spec/fixtures/output_2.xml
74
+ - spec/fixtures/output_3_c14n_comments.xml
73
75
  - spec/signer_spec.rb
74
76
  - spec/spec_helper.rb
75
77
  homepage: ''
@@ -99,8 +101,10 @@ test_files:
99
101
  - spec/fixtures/cert.pem
100
102
  - spec/fixtures/input_1.xml
101
103
  - spec/fixtures/input_2.xml
104
+ - spec/fixtures/input_3_c14n_comments.xml
102
105
  - spec/fixtures/key.pem
103
106
  - spec/fixtures/output_1.xml
104
107
  - spec/fixtures/output_2.xml
108
+ - spec/fixtures/output_3_c14n_comments.xml
105
109
  - spec/signer_spec.rb
106
110
  - spec/spec_helper.rb