async-rspec 1.3.1 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/async/rspec/ssl.rb +67 -1
- data/lib/async/rspec/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e3740c7d6640f8341b9c748d5d992e3fe815fb404c0096077de47f42437d9464
|
4
|
+
data.tar.gz: a0e097113adadf7e7e5483cb2bf62184af9162d2f5320c9e38b95e7f94236142
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1512325a47c8ee2c63336b598b3767545a8a0e85709c7ad2f2ff81620634a3cca389e29867609127f9e9699d814a67fb5318f7e5cea7be551aa274483f240a80
|
7
|
+
data.tar.gz: fac2caaeaccc3b7206647f9a9456d106da12edd2745712d7b574ee35abee5b370abe6d8c46a92c164419c18666dcf69eb824631280b73a6b3c05c92cea796053
|
data/lib/async/rspec/ssl.rb
CHANGED
@@ -34,6 +34,9 @@ module Async
|
|
34
34
|
|
35
35
|
module VerifiedContexts
|
36
36
|
end
|
37
|
+
|
38
|
+
module HostCertificates
|
39
|
+
end
|
37
40
|
end
|
38
41
|
|
39
42
|
RSpec.shared_context SSL::CertificateAuthority do
|
@@ -57,7 +60,7 @@ module Async
|
|
57
60
|
certificate.not_before = Time.now
|
58
61
|
certificate.not_after = Time.now + 3600
|
59
62
|
|
60
|
-
extension_factory = OpenSSL::X509::ExtensionFactory.new
|
63
|
+
extension_factory = OpenSSL::X509::ExtensionFactory.new
|
61
64
|
extension_factory.subject_certificate = certificate
|
62
65
|
extension_factory.issuer_certificate = certificate
|
63
66
|
certificate.add_extension extension_factory.create_extension("basicConstraints", "CA:TRUE", true)
|
@@ -107,6 +110,69 @@ module Async
|
|
107
110
|
end
|
108
111
|
end
|
109
112
|
|
113
|
+
RSpec.shared_context SSL::HostCertificates do
|
114
|
+
include_context SSL::CertificateAuthority
|
115
|
+
|
116
|
+
let(:keys) do
|
117
|
+
Hash[
|
118
|
+
hosts.collect{|name| [name, OpenSSL::PKey::RSA.new(1024)]}
|
119
|
+
]
|
120
|
+
end
|
121
|
+
|
122
|
+
# The certificate used for actual communication:
|
123
|
+
let(:certificates) do
|
124
|
+
Hash[
|
125
|
+
hosts.collect do |name|
|
126
|
+
certificate_name = OpenSSL::X509::Name.parse("O=Test/CN=#{name}")
|
127
|
+
|
128
|
+
certificate = OpenSSL::X509::Certificate.new
|
129
|
+
certificate.subject = certificate_name
|
130
|
+
certificate.issuer = certificate_authority.subject
|
131
|
+
|
132
|
+
certificate.public_key = keys[name].public_key
|
133
|
+
|
134
|
+
certificate.serial = 2
|
135
|
+
certificate.version = 2
|
136
|
+
|
137
|
+
certificate.not_before = Time.now
|
138
|
+
certificate.not_after = Time.now + 3600
|
139
|
+
|
140
|
+
extension_factory = OpenSSL::X509::ExtensionFactory.new
|
141
|
+
extension_factory.subject_certificate = certificate
|
142
|
+
extension_factory.issuer_certificate = certificate_authority
|
143
|
+
certificate.add_extension extension_factory.create_extension("keyUsage", "digitalSignature", true)
|
144
|
+
certificate.add_extension extension_factory.create_extension("subjectKeyIdentifier", "hash")
|
145
|
+
|
146
|
+
certificate.sign certificate_authority_key, OpenSSL::Digest::SHA256.new
|
147
|
+
|
148
|
+
[name, certificate]
|
149
|
+
end
|
150
|
+
]
|
151
|
+
end
|
152
|
+
|
153
|
+
let(:server_context) do
|
154
|
+
OpenSSL::SSL::SSLContext.new.tap do |context|
|
155
|
+
context.servername_cb = Proc.new do |socket, name|
|
156
|
+
if hosts.include? name
|
157
|
+
socket.hostname = name
|
158
|
+
|
159
|
+
OpenSSL::SSL::SSLContext.new.tap do |context|
|
160
|
+
context.cert = certificates[name]
|
161
|
+
context.key = keys[name]
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
let(:client_context) do
|
169
|
+
OpenSSL::SSL::SSLContext.new.tap do |context|
|
170
|
+
context.cert_store = certificate_store
|
171
|
+
context.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
172
|
+
end
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
110
176
|
RSpec.shared_context SSL::InvalidCertificate do
|
111
177
|
include_context SSL::CertificateAuthority
|
112
178
|
|
data/lib/async/rspec/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: async-rspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-04-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|