Skip to content

Commit 71b887b

Browse files
committed
(PUP-11522) Ensure test is using the SSL_CERT_FILE
Previously, the test passed the CA cert to `create_context` and set SSL_CERT_FILE, so it was possible for the test to pass when it shouldn't. Now only do the latter to verify we can indeed connect when loading a CA from the "system store" aka wherever openssl looks for trusted certs. Also rename "system store" variable to "cert_file" to avoid confusion later when the file is used to contain certs in an "external" store.
1 parent a032e52 commit 71b887b

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

spec/integration/http/client_spec.rb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@
7777
}
7878
}
7979

80-
let(:systemstore) do
81-
res = tmpfile('systemstore')
80+
let(:cert_file) do
81+
res = tmpfile('cert_file')
8282
File.write(res, https_server.ca_cert)
8383
res
8484
end
@@ -96,9 +96,9 @@
9696
end
9797

9898
it "connects when the server's CA is in the system store and the connection is mutually authenticated using create_context" do
99-
Puppet::Util.withenv("SSL_CERT_FILE" => systemstore) do
99+
Puppet::Util.withenv("SSL_CERT_FILE" => cert_file) do
100100
client_context = ssl_provider.create_context(
101-
cacerts: [https_server.ca_cert], crls: [https_server.ca_crl],
101+
cacerts: [], crls: [],
102102
client_cert: https_server.server_cert, private_key: https_server.server_key,
103103
revocation: false, include_system_store: true
104104
)
@@ -109,8 +109,8 @@
109109
end
110110
end
111111

112-
it "connects when the server's CA is in the system store and the connection is mutually authenticated uning load_context" do
113-
Puppet::Util.withenv("SSL_CERT_FILE" => systemstore) do
112+
it "connects when the server's CA is in the system store and the connection is mutually authenticated using load_context" do
113+
Puppet::Util.withenv("SSL_CERT_FILE" => cert_file) do
114114
client_context = ssl_provider.load_context(revocation: false, include_system_store: true)
115115
https_server.start_server(ctx_proc: ctx_proc) do |port|
116116
res = client.get(URI("https://127.0.0.1:#{port}"), options: {ssl_context: client_context})
@@ -132,12 +132,12 @@
132132

133133
it "connects when the server's CA is in the system store" do
134134
# create a temp cacert bundle
135-
ssl_file = tmpfile('systemstore')
136-
File.write(ssl_file, https_server.ca_cert)
135+
cert_file = tmpfile('cert_file')
136+
File.write(cert_file, https_server.ca_cert)
137137

138138
# override path to system cacert bundle, this must be done before
139139
# the SSLContext is created and the call to X509::Store.set_default_paths
140-
Puppet::Util.withenv("SSL_CERT_FILE" => ssl_file) do
140+
Puppet::Util.withenv("SSL_CERT_FILE" => cert_file) do
141141
system_context = ssl_provider.create_system_context(cacerts: [])
142142
https_server.start_server do |port|
143143
res = client.get(URI("https://127.0.0.1:#{port}"), options: {ssl_context: system_context})

0 commit comments

Comments
 (0)