|
211 | 211 | describe "setting an encrypted client private key, w/an incorrect passphrase" do |
212 | 212 | let(:key_pass) { "ttqm" } |
213 | 213 |
|
214 | | - it "raises an OpenSSL::PKey::RSAError exception" do |
| 214 | + it "raises an exception" do |
215 | 215 | expect(client.ssl_context.key).to be_nil |
216 | 216 | expect { client.key_file = [fixture_path("client.pass.key"), key_pass] }.to( |
217 | | - raise_error(OpenSSL::PKey::RSAError, /Neither PUB key nor PRIV key/) |
| 217 | + raise_error(/Could not parse PKey/) |
| 218 | + ) |
| 219 | + end |
| 220 | + end |
| 221 | + |
| 222 | + describe "setting a client private EC key file path" do |
| 223 | + it "adds a certificate to the SSL context" do |
| 224 | + expect(client.ssl_context.key).to be_nil |
| 225 | + client.key_file = fixture_path("ec.key") |
| 226 | + expect(client.ssl_context.key).to be_a(OpenSSL::PKey::EC) |
| 227 | + end |
| 228 | + end |
| 229 | + |
| 230 | + describe "setting a client private EC key directly" do |
| 231 | + it "adds a certificate to the SSL context" do |
| 232 | + expect(client.ssl_context.key).to be_nil |
| 233 | + client.key = File.read(fixture_path("ec.key")) |
| 234 | + expect(client.ssl_context.key).to be_a(OpenSSL::PKey::EC) |
| 235 | + end |
| 236 | + end |
| 237 | + |
| 238 | + describe "setting an encrypted client private EC key, w/the correct passphrase" do |
| 239 | + let(:key_pass) { "mqtt" } |
| 240 | + |
| 241 | + it "adds the decrypted certificate to the SSL context" do |
| 242 | + expect(client.ssl_context.key).to be_nil |
| 243 | + client.key_file = [fixture_path("ec.pass.key"), key_pass] |
| 244 | + expect(client.ssl_context.key).to be_a(OpenSSL::PKey::EC) |
| 245 | + end |
| 246 | + end |
| 247 | + |
| 248 | + describe "setting an encrypted client private EC key, w/an incorrect passphrase" do |
| 249 | + let(:key_pass) { "ttqm" } |
| 250 | + |
| 251 | + it "raises an exception" do |
| 252 | + expect(client.ssl_context.key).to be_nil |
| 253 | + expect { client.key_file = [fixture_path("ec.pass.key"), key_pass] }.to( |
| 254 | + raise_error(/Could not parse PKey/) |
218 | 255 | ) |
219 | 256 | end |
220 | 257 | end |
|
0 commit comments