openssl-extensions 1.0.0 → 1.1.0
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.
- data/CHANGELOG.md +6 -2
- data/lib/openssl-extensions/all.rb +1 -0
- data/lib/openssl-extensions/pkey.rb +4 -0
- data/lib/openssl-extensions/pkey/pkey.rb +19 -0
- data/lib/openssl-extensions/version.rb +1 -1
- data/spec/fixtures/keys/dsa.key +20 -0
- data/spec/fixtures/keys/rsa.key +27 -0
- data/spec/integration/openssl/pkey/pkey_spec.rb +9 -0
- data/spec/models/openssl-extensions/pkey/pkey_spec.rb +32 -0
- data/spec/support/pkey_fixtures.rb +46 -0
- metadata +20 -3
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,10 @@
|
|
1
|
+
## 1.1.0, released 2011-01-20
|
2
|
+
|
3
|
+
* Extended OpenSSL::PKey::PKey to add equality methods.
|
4
|
+
|
1
5
|
## 1.0.0, released 2011-01-17
|
2
6
|
|
3
7
|
* Initial major release.
|
4
|
-
*
|
5
|
-
*
|
8
|
+
* Extended OpenSSL::X509::Request, OpenSSL::X509::Certificate, OpenSSL::X509::Name
|
9
|
+
* Added OpenSSLExtensions::X509::CertificateChain and OpenSSLExtensions::X509::AuthorityKeyIdentifier
|
6
10
|
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'openssl-extensions'
|
2
|
+
require 'openssl-extensions/pkey'
|
3
|
+
|
4
|
+
##
|
5
|
+
# Extends OpenSSL::PKey::PKey and its submodules with helper methods.
|
6
|
+
#
|
7
|
+
module OpenSSLExtensions::PKey::PKey
|
8
|
+
def ==(other)
|
9
|
+
other.kind_of?(OpenSSL::PKey::PKey) &&
|
10
|
+
self.hash == other.hash
|
11
|
+
end
|
12
|
+
alias_method :eql?, :==
|
13
|
+
|
14
|
+
def hash
|
15
|
+
to_pem.hash
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
OpenSSL::PKey::PKey.send(:include, OpenSSLExtensions::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kAi73KB3hf4amT0q3Ku
|
27
|
+
-----END RSA PRIVATE KEY-----
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe OpenSSLExtensions::PKey::PKey do
|
4
|
+
subject { extended_pkeys('rsa') }
|
5
|
+
|
6
|
+
context '==' do
|
7
|
+
it 'is true for matching keys' do
|
8
|
+
subject.should == extended_pkeys('rsa')
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'is false for mismatched keys' do
|
12
|
+
subject.should_not == extended_pkeys('dsa')
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'eql?' do
|
17
|
+
it 'is true for matching keys' do
|
18
|
+
subject.should be_eql extended_pkeys('rsa')
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'is false for mismatched keys' do
|
22
|
+
subject.should_not be_eql extended_pkeys('dsa')
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
context 'hash' do
|
27
|
+
it 'returns the hash of the PEM string' do
|
28
|
+
subject.stub!(:to_pem => mock('PEM', :hash => 'test'))
|
29
|
+
subject.hash
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module PKeyFixtures
|
2
|
+
##
|
3
|
+
# Returns an OpenSSL::X509::Certificate without explicit extensions.
|
4
|
+
#
|
5
|
+
def pkeys(name)
|
6
|
+
name = name.to_s.downcase.gsub(/[^\w\.]/, '-')
|
7
|
+
pkey_path = File.expand_path("../../fixtures/keys/#{name}.key", __FILE__)
|
8
|
+
key = nil
|
9
|
+
|
10
|
+
if File.exist?(pkey_path) && File.readable?(pkey_path)
|
11
|
+
data = File.read(pkey_path)
|
12
|
+
key = [
|
13
|
+
OpenSSL::PKey::RSA,
|
14
|
+
OpenSSL::PKey::DSA,
|
15
|
+
OpenSSL::PKey::EC,
|
16
|
+
OpenSSL::PKey::DH
|
17
|
+
].collect { |klass| instantiate_pkey(data, klass) }.
|
18
|
+
detect { |key| !key.nil? }
|
19
|
+
data = nil
|
20
|
+
end
|
21
|
+
|
22
|
+
key
|
23
|
+
end
|
24
|
+
|
25
|
+
##
|
26
|
+
# Returns an OpenSSL::PKey explicitly extended with
|
27
|
+
# OpenSSLExtensions::PKey::PKey.
|
28
|
+
#
|
29
|
+
def extended_pkeys(name)
|
30
|
+
pkeys(name).extend(OpenSSLExtensions::PKey::PKey)
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
protected
|
35
|
+
|
36
|
+
|
37
|
+
def instantiate_pkey(data, klass)
|
38
|
+
klass.new(data)
|
39
|
+
rescue OpenSSL::PKey::PKeyError
|
40
|
+
nil
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
RSpec.configure do |config|
|
45
|
+
config.include PKeyFixtures
|
46
|
+
end
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: openssl-extensions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 19
|
4
5
|
prerelease: false
|
5
6
|
segments:
|
6
7
|
- 1
|
8
|
+
- 1
|
7
9
|
- 0
|
8
|
-
|
9
|
-
version: 1.0.0
|
10
|
+
version: 1.1.0
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Nathaniel Bibler
|
@@ -14,7 +15,7 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date: 2011-01-
|
18
|
+
date: 2011-01-20 00:00:00 -05:00
|
18
19
|
default_executable:
|
19
20
|
dependencies:
|
20
21
|
- !ruby/object:Gem::Dependency
|
@@ -25,6 +26,7 @@ dependencies:
|
|
25
26
|
requirements:
|
26
27
|
- - ~>
|
27
28
|
- !ruby/object:Gem::Version
|
29
|
+
hash: 31
|
28
30
|
segments:
|
29
31
|
- 2
|
30
32
|
- 4
|
@@ -40,6 +42,7 @@ dependencies:
|
|
40
42
|
requirements:
|
41
43
|
- - ~>
|
42
44
|
- !ruby/object:Gem::Version
|
45
|
+
hash: 29
|
43
46
|
segments:
|
44
47
|
- 0
|
45
48
|
- 0
|
@@ -58,6 +61,8 @@ extra_rdoc_files: []
|
|
58
61
|
|
59
62
|
files:
|
60
63
|
- lib/openssl-extensions/all.rb
|
64
|
+
- lib/openssl-extensions/pkey/pkey.rb
|
65
|
+
- lib/openssl-extensions/pkey.rb
|
61
66
|
- lib/openssl-extensions/ssl/ssl_socket.rb
|
62
67
|
- lib/openssl-extensions/ssl.rb
|
63
68
|
- lib/openssl-extensions/version.rb
|
@@ -89,10 +94,14 @@ files:
|
|
89
94
|
- spec/fixtures/certificates/hongkong-post-root-ca.pem
|
90
95
|
- spec/fixtures/certificates/www.geocerts.com.pem
|
91
96
|
- spec/fixtures/certificates/www.twongo.com.pem
|
97
|
+
- spec/fixtures/keys/dsa.key
|
98
|
+
- spec/fixtures/keys/rsa.key
|
99
|
+
- spec/integration/openssl/pkey/pkey_spec.rb
|
92
100
|
- spec/integration/openssl/ssl/ssl_socket_spec.rb
|
93
101
|
- spec/integration/openssl/x509/certificate_spec.rb
|
94
102
|
- spec/integration/openssl/x509/name_spec.rb
|
95
103
|
- spec/integration/openssl/x509/request_spec.rb
|
104
|
+
- spec/models/openssl-extensions/pkey/pkey_spec.rb
|
96
105
|
- spec/models/openssl-extensions/ssl/ssl_socket_spec.rb
|
97
106
|
- spec/models/openssl-extensions/x509/authority_key_identifier_spec.rb
|
98
107
|
- spec/models/openssl-extensions/x509/certificate_chain_spec.rb
|
@@ -102,6 +111,7 @@ files:
|
|
102
111
|
- spec/models/openssl-extensions_spec.rb
|
103
112
|
- spec/spec_helper.rb
|
104
113
|
- spec/support/certificate_request_fixtures.rb
|
114
|
+
- spec/support/pkey_fixtures.rb
|
105
115
|
- spec/support/ssl_certificate_fixtures.rb
|
106
116
|
has_rdoc: true
|
107
117
|
homepage: http://github.com/envylabs/openssl-extensions
|
@@ -117,6 +127,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
117
127
|
requirements:
|
118
128
|
- - ">="
|
119
129
|
- !ruby/object:Gem::Version
|
130
|
+
hash: 3
|
120
131
|
segments:
|
121
132
|
- 0
|
122
133
|
version: "0"
|
@@ -125,6 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
125
136
|
requirements:
|
126
137
|
- - ">="
|
127
138
|
- !ruby/object:Gem::Version
|
139
|
+
hash: 23
|
128
140
|
segments:
|
129
141
|
- 1
|
130
142
|
- 3
|
@@ -156,10 +168,14 @@ test_files:
|
|
156
168
|
- spec/fixtures/certificates/hongkong-post-root-ca.pem
|
157
169
|
- spec/fixtures/certificates/www.geocerts.com.pem
|
158
170
|
- spec/fixtures/certificates/www.twongo.com.pem
|
171
|
+
- spec/fixtures/keys/dsa.key
|
172
|
+
- spec/fixtures/keys/rsa.key
|
173
|
+
- spec/integration/openssl/pkey/pkey_spec.rb
|
159
174
|
- spec/integration/openssl/ssl/ssl_socket_spec.rb
|
160
175
|
- spec/integration/openssl/x509/certificate_spec.rb
|
161
176
|
- spec/integration/openssl/x509/name_spec.rb
|
162
177
|
- spec/integration/openssl/x509/request_spec.rb
|
178
|
+
- spec/models/openssl-extensions/pkey/pkey_spec.rb
|
163
179
|
- spec/models/openssl-extensions/ssl/ssl_socket_spec.rb
|
164
180
|
- spec/models/openssl-extensions/x509/authority_key_identifier_spec.rb
|
165
181
|
- spec/models/openssl-extensions/x509/certificate_chain_spec.rb
|
@@ -169,4 +185,5 @@ test_files:
|
|
169
185
|
- spec/models/openssl-extensions_spec.rb
|
170
186
|
- spec/spec_helper.rb
|
171
187
|
- spec/support/certificate_request_fixtures.rb
|
188
|
+
- spec/support/pkey_fixtures.rb
|
172
189
|
- spec/support/ssl_certificate_fixtures.rb
|