nokogiri-xmlsec-ap 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +21 -0
- data/.rspec +2 -0
- data/Gemfile +4 -0
- data/Guardfile +13 -0
- data/LICENSE.txt +22 -0
- data/README.md +121 -0
- data/Rakefile +30 -0
- data/ext/nokogiri_ext_xmlsec/extconf.rb +20 -0
- data/ext/nokogiri_ext_xmlsec/init.c +46 -0
- data/ext/nokogiri_ext_xmlsec/nokogiri_decrypt_with_key.c +124 -0
- data/ext/nokogiri_ext_xmlsec/nokogiri_encrypt_with_key.c +177 -0
- data/ext/nokogiri_ext_xmlsec/nokogiri_helpers_set_attribute_id.c +43 -0
- data/ext/nokogiri_ext_xmlsec/nokogiri_init.c +32 -0
- data/ext/nokogiri_ext_xmlsec/nokogiri_sign_certificate.c +143 -0
- data/ext/nokogiri_ext_xmlsec/nokogiri_sign_rsa.c +95 -0
- data/ext/nokogiri_ext_xmlsec/nokogiri_verify_signature_certificates.c +96 -0
- data/ext/nokogiri_ext_xmlsec/nokogiri_verify_signature_named_keys.c +106 -0
- data/ext/nokogiri_ext_xmlsec/nokogiri_verify_signature_rsa.c +56 -0
- data/ext/nokogiri_ext_xmlsec/shutdown.c +12 -0
- data/ext/nokogiri_ext_xmlsec/xmlsecrb.h +39 -0
- data/lib/nokogiri-xmlsec.rb +1 -0
- data/lib/xmlsec.rb +110 -0
- data/lib/xmlsec/version.rb +3 -0
- data/nokogiri-xmlsec.gemspec +36 -0
- data/spec/fixtures/cert/server.crt +14 -0
- data/spec/fixtures/cert/server.csr +11 -0
- data/spec/fixtures/cert/server.key.decrypted +15 -0
- data/spec/fixtures/cert/server.key.encrypted +18 -0
- data/spec/fixtures/rsa.pem +15 -0
- data/spec/fixtures/rsa.pub +6 -0
- data/spec/fixtures/sign2-doc.xml +6 -0
- data/spec/fixtures/sign2-result.xml +24 -0
- data/spec/fixtures/sign3-result.xml +37 -0
- data/spec/lib/nokogiri/xml/document/encryption_and_decryption_spec.rb +28 -0
- data/spec/lib/nokogiri/xml/document/signing_and_verifying_spec.rb +70 -0
- data/spec/spec_helper.rb +10 -0
- metadata +197 -0
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "signing and verifying signatures:" do
|
4
|
+
subject do
|
5
|
+
Nokogiri::XML(fixture('sign2-doc.xml'))
|
6
|
+
end
|
7
|
+
|
8
|
+
describe 'signing a document with an RSA key' do
|
9
|
+
before { subject.sign! key: fixture('rsa.pem'), name: 'test' }
|
10
|
+
|
11
|
+
it 'should produce a signed document' do
|
12
|
+
subject.to_s.should == fixture('sign2-result.xml')
|
13
|
+
end
|
14
|
+
|
15
|
+
describe 'verifying the document with a single public key' do
|
16
|
+
it 'should be valid' do
|
17
|
+
subject.verify_with(key: fixture('rsa.pub')).should == true
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe 'verifying the document with a set of keys' do
|
22
|
+
it 'should be valid' do
|
23
|
+
subject.verify_with({
|
24
|
+
'test' => fixture('rsa.pub')
|
25
|
+
}).should == true
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe 'signing a document with an RSA key and X509 certificate' do
|
31
|
+
before do
|
32
|
+
subject.sign! key: fixture('cert/server.key.decrypted'),
|
33
|
+
name: 'test',
|
34
|
+
x509: fixture('cert/server.crt')
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'should produce a signed document' do
|
38
|
+
subject.to_s.should == fixture('sign3-result.xml')
|
39
|
+
end
|
40
|
+
|
41
|
+
describe 'verifying the document with an array of X509 certificates' do
|
42
|
+
specify { subject.verify_with(x509: [fixture('cert/server.crt')]).should == true }
|
43
|
+
specify { subject.verify_with(certs: [fixture('cert/server.crt')]).should == true }
|
44
|
+
specify { subject.verify_with(certificates: [fixture('cert/server.crt')]).should == true }
|
45
|
+
|
46
|
+
it 'should verify using system certificates' do
|
47
|
+
# subject.verify_signature.should == true -- sort of.
|
48
|
+
unless subject.verify_signature
|
49
|
+
raise <<-end_error
|
50
|
+
Could not use system certificates to verify the signature.
|
51
|
+
Note that this may not be a failing spec. You should copy
|
52
|
+
or symlink the file `spec/fixtures/cert/server.crt` into
|
53
|
+
the directory shown by running `openssl version -d`. After
|
54
|
+
doing so, run `sudo c_rehash CERT_PATH`, where
|
55
|
+
CERT_PATH is the same directory you copied the certificate
|
56
|
+
into (/usr/lib/ssl/certs by default on Ubuntu). After doing
|
57
|
+
that, run this spec again and see if it passes.
|
58
|
+
end_error
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
describe 'verifying the document with one X509 certificate' do
|
64
|
+
specify { subject.verify_with(x509: fixture('cert/server.crt')).should == true }
|
65
|
+
specify { subject.verify_with(cert: fixture('cert/server.crt')).should == true }
|
66
|
+
specify { subject.verify_with(certificate: fixture('cert/server.crt')).should == true }
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,197 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: nokogiri-xmlsec-ap
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.5
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Colin MacKenzie IV
|
8
|
+
- Justin Feng
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2021-08-05 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: nokogiri
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - ">="
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '0'
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '0'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: bundler
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: rake
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ">="
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: rake-compiler
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: rspec
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
- !ruby/object:Gem::Dependency
|
85
|
+
name: guard-rspec
|
86
|
+
requirement: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
type: :development
|
92
|
+
prerelease: false
|
93
|
+
version_requirements: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
98
|
+
- !ruby/object:Gem::Dependency
|
99
|
+
name: guard-rake
|
100
|
+
requirement: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
type: :development
|
106
|
+
prerelease: false
|
107
|
+
version_requirements: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - ">="
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0'
|
112
|
+
description: |-
|
113
|
+
Adds support to Ruby for encrypting, decrypting,
|
114
|
+
signing and validating the signatures of XML documents, according to the
|
115
|
+
[XML Encryption Syntax and Processing](http://www.w3.org/TR/xmlenc-core/)
|
116
|
+
standard, by wrapping around the [xmlsec](http://www.aleksey.com/xmlsec) C
|
117
|
+
library and adding relevant methods to `Nokogiri::XML::Document`.
|
118
|
+
email:
|
119
|
+
- justin.feng@afterpay.com
|
120
|
+
executables: []
|
121
|
+
extensions:
|
122
|
+
- ext/nokogiri_ext_xmlsec/extconf.rb
|
123
|
+
extra_rdoc_files: []
|
124
|
+
files:
|
125
|
+
- ".gitignore"
|
126
|
+
- ".rspec"
|
127
|
+
- Gemfile
|
128
|
+
- Guardfile
|
129
|
+
- LICENSE.txt
|
130
|
+
- README.md
|
131
|
+
- Rakefile
|
132
|
+
- ext/nokogiri_ext_xmlsec/extconf.rb
|
133
|
+
- ext/nokogiri_ext_xmlsec/init.c
|
134
|
+
- ext/nokogiri_ext_xmlsec/nokogiri_decrypt_with_key.c
|
135
|
+
- ext/nokogiri_ext_xmlsec/nokogiri_encrypt_with_key.c
|
136
|
+
- ext/nokogiri_ext_xmlsec/nokogiri_helpers_set_attribute_id.c
|
137
|
+
- ext/nokogiri_ext_xmlsec/nokogiri_init.c
|
138
|
+
- ext/nokogiri_ext_xmlsec/nokogiri_sign_certificate.c
|
139
|
+
- ext/nokogiri_ext_xmlsec/nokogiri_sign_rsa.c
|
140
|
+
- ext/nokogiri_ext_xmlsec/nokogiri_verify_signature_certificates.c
|
141
|
+
- ext/nokogiri_ext_xmlsec/nokogiri_verify_signature_named_keys.c
|
142
|
+
- ext/nokogiri_ext_xmlsec/nokogiri_verify_signature_rsa.c
|
143
|
+
- ext/nokogiri_ext_xmlsec/shutdown.c
|
144
|
+
- ext/nokogiri_ext_xmlsec/xmlsecrb.h
|
145
|
+
- lib/nokogiri-xmlsec.rb
|
146
|
+
- lib/xmlsec.rb
|
147
|
+
- lib/xmlsec/version.rb
|
148
|
+
- nokogiri-xmlsec.gemspec
|
149
|
+
- spec/fixtures/cert/server.crt
|
150
|
+
- spec/fixtures/cert/server.csr
|
151
|
+
- spec/fixtures/cert/server.key.decrypted
|
152
|
+
- spec/fixtures/cert/server.key.encrypted
|
153
|
+
- spec/fixtures/rsa.pem
|
154
|
+
- spec/fixtures/rsa.pub
|
155
|
+
- spec/fixtures/sign2-doc.xml
|
156
|
+
- spec/fixtures/sign2-result.xml
|
157
|
+
- spec/fixtures/sign3-result.xml
|
158
|
+
- spec/lib/nokogiri/xml/document/encryption_and_decryption_spec.rb
|
159
|
+
- spec/lib/nokogiri/xml/document/signing_and_verifying_spec.rb
|
160
|
+
- spec/spec_helper.rb
|
161
|
+
homepage: https://github.com/justinfeng-ap/xmlsec
|
162
|
+
licenses:
|
163
|
+
- MIT
|
164
|
+
metadata: {}
|
165
|
+
post_install_message:
|
166
|
+
rdoc_options: []
|
167
|
+
require_paths:
|
168
|
+
- lib
|
169
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - ">="
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
175
|
+
requirements:
|
176
|
+
- - ">="
|
177
|
+
- !ruby/object:Gem::Version
|
178
|
+
version: '0'
|
179
|
+
requirements: []
|
180
|
+
rubygems_version: 3.2.3
|
181
|
+
signing_key:
|
182
|
+
specification_version: 4
|
183
|
+
summary: Wrapper around http://www.aleksey.com/xmlsec to support XML encryption, decryption,
|
184
|
+
signing and signature validation in Ruby
|
185
|
+
test_files:
|
186
|
+
- spec/fixtures/cert/server.crt
|
187
|
+
- spec/fixtures/cert/server.csr
|
188
|
+
- spec/fixtures/cert/server.key.decrypted
|
189
|
+
- spec/fixtures/cert/server.key.encrypted
|
190
|
+
- spec/fixtures/rsa.pem
|
191
|
+
- spec/fixtures/rsa.pub
|
192
|
+
- spec/fixtures/sign2-doc.xml
|
193
|
+
- spec/fixtures/sign2-result.xml
|
194
|
+
- spec/fixtures/sign3-result.xml
|
195
|
+
- spec/lib/nokogiri/xml/document/encryption_and_decryption_spec.rb
|
196
|
+
- spec/lib/nokogiri/xml/document/signing_and_verifying_spec.rb
|
197
|
+
- spec/spec_helper.rb
|