|
113 | 113 | }.to raise_error(/can't modify frozen/)
|
114 | 114 | end
|
115 | 115 |
|
116 |
| - it 'trusts system ca store' do |
| 116 | + it 'trusts system ca store by default' do |
117 | 117 | expect_any_instance_of(OpenSSL::X509::Store).to receive(:set_default_paths)
|
118 | 118 |
|
119 | 119 | subject.create_system_context(cacerts: [])
|
120 | 120 | end
|
121 | 121 |
|
| 122 | + it 'trusts an external ca store' do |
| 123 | + path = tmpfile('system_cacerts') |
| 124 | + File.write(path, cert_fixture('ca.pem').to_pem) |
| 125 | + |
| 126 | + expect_any_instance_of(OpenSSL::X509::Store).to receive(:add_file).with(path) |
| 127 | + |
| 128 | + subject.create_system_context(cacerts: [], path: path) |
| 129 | + end |
| 130 | + |
122 | 131 | it 'verifies peer' do
|
123 | 132 | sslctx = subject.create_system_context(cacerts: [])
|
124 | 133 | expect(sslctx.verify_peer).to eq(true)
|
|
448 | 457 | sslctx = subject.create_context(**config)
|
449 | 458 | expect(sslctx.verify_peer).to eq(true)
|
450 | 459 | end
|
| 460 | + |
| 461 | + it 'does not trust the system ca store by default' do |
| 462 | + expect_any_instance_of(OpenSSL::X509::Store).to receive(:set_default_paths).never |
| 463 | + |
| 464 | + subject.create_context(**config) |
| 465 | + end |
| 466 | + |
| 467 | + it 'trusts the system ca store' do |
| 468 | + expect_any_instance_of(OpenSSL::X509::Store).to receive(:set_default_paths) |
| 469 | + |
| 470 | + subject.create_context(**config.merge(include_system_store: true)) |
| 471 | + end |
451 | 472 | end
|
452 | 473 |
|
453 | 474 | context 'when loading an ssl context' do
|
|
528 | 549 | subject.load_context(password: 'wrongpassword')
|
529 | 550 | }.to raise_error(Puppet::SSL::SSLError, /Failed to load private key for host 'signed': Could not parse PKey/)
|
530 | 551 | end
|
| 552 | + |
| 553 | + it 'does not trust the system ca store by default' do |
| 554 | + expect_any_instance_of(OpenSSL::X509::Store).to receive(:set_default_paths).never |
| 555 | + |
| 556 | + subject.load_context |
| 557 | + end |
| 558 | + |
| 559 | + it 'trusts the system ca store' do |
| 560 | + expect_any_instance_of(OpenSSL::X509::Store).to receive(:set_default_paths) |
| 561 | + |
| 562 | + subject.load_context(include_system_store: true) |
| 563 | + end |
531 | 564 | end
|
532 | 565 |
|
533 | 566 | context 'when verifying requests' do
|
|
0 commit comments