Skip to content

Commit ecfa274

Browse files
committed
Merge branch 'ca-certs'
2 parents 69f91d8 + b457d24 commit ecfa274

4 files changed

Lines changed: 16 additions & 10 deletions

File tree

.idea/dictionaries/bhale.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/java_buildpack/util/cache/download_cache.rb

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def evict(uri)
7777

7878
private
7979

80-
CA_CERTS_DIRECTORY = (Pathname.new(__FILE__).dirname + '../../../../resources/ca_certs').freeze
80+
CA_FILE = (Pathname.new(__FILE__).dirname + '../../../../resources/ca_certs.pem').freeze
8181

8282
FAILURE_LIMIT = 5.freeze
8383

@@ -112,7 +112,7 @@ def evict(uri)
112112

113113
TIMEOUT_SECONDS = 10.freeze
114114

115-
private_constant :CA_CERTS_DIRECTORY, :FAILURE_LIMIT, :HTTP_ERRORS, :REDIRECT_TYPES, :TIMEOUT_SECONDS
115+
private_constant :CA_FILE, :FAILURE_LIMIT, :HTTP_ERRORS, :REDIRECT_TYPES, :TIMEOUT_SECONDS
116116

117117
def attempt(http, request, cached_file)
118118
downloaded = false
@@ -208,7 +208,12 @@ def http_options(rich_uri)
208208

209209
if secure?(rich_uri)
210210
http_options[:use_ssl] = true
211-
http_options[:ca_path] = CA_CERTS_DIRECTORY.to_s if CA_CERTS_DIRECTORY.exist?
211+
@logger.debug { 'Adding HTTP options for secure connection' }
212+
213+
if CA_FILE.exist?
214+
http_options[:ca_file] = CA_FILE.to_s
215+
@logger.debug { "Adding additional certs from #{CA_FILE}" }
216+
end
212217
end
213218

214219
http_options

spec/bin/detect_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
end
3838

3939
it 'should truncate long detect strings',
40-
app_fixture: 'integration_valid',
40+
app_fixture: 'integration_valid',
4141
buildpack_fixture: 'integration_long_detect_tag' do
4242

4343
run("bin/detect #{app_dir}") do |status|

spec/java_buildpack/util/cache/download_cache_spec.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
let(:download_cache) { described_class.new(mutable_cache_root, immutable_cache_root) }
4343

4444
before do
45-
described_class.const_set :CA_CERTS_DIRECTORY, ca_certs_directory
45+
described_class.const_set :CA_FILE, ca_certs_directory
4646
end
4747

4848
it 'should raise error if file cannot be found',
@@ -234,7 +234,7 @@
234234

235235
end
236236

237-
it 'should not use ca_path if the URL is not secure and directory does not exist' do
237+
it 'should not use ca_file if the URL is not secure and directory does not exist' do
238238
stub_request(:get, uri)
239239
.to_return(status: 200, body: 'foo-cached', headers: { Etag: 'foo-etag', 'Last-Modified' => 'foo-last-modified' })
240240

@@ -245,7 +245,7 @@
245245
download_cache.get(uri) {}
246246
end
247247

248-
it 'should not use ca_path if the URL is not secure and directory does exist' do
248+
it 'should not use ca_file if the URL is not secure and directory does exist' do
249249
stub_request(:get, uri)
250250
.to_return(status: 200, body: 'foo-cached', headers: { Etag: 'foo-etag', 'Last-Modified' => 'foo-last-modified' })
251251

@@ -257,7 +257,7 @@
257257
download_cache.get(uri) {}
258258
end
259259

260-
it 'should not use ca_path if the URL is secure and directory does not exist' do
260+
it 'should not use ca_file if the URL is secure and directory does not exist' do
261261
stub_request(:get, uri_secure)
262262
.to_return(status: 200, body: 'foo-cached', headers: { Etag: 'foo-etag', 'Last-Modified' => 'foo-last-modified' })
263263

@@ -269,15 +269,15 @@
269269
download_cache.get(uri_secure) {}
270270
end
271271

272-
it 'should use ca_path if the URL is secure and directory does exist' do
272+
it 'should use ca_file if the URL is secure and directory does exist' do
273273
stub_request(:get, uri_secure)
274274
.to_return(status: 200, body: 'foo-cached', headers: { Etag: 'foo-etag', 'Last-Modified' => 'foo-last-modified' })
275275

276276
allow(ca_certs_directory).to receive(:exist?).and_return(true)
277277
allow(Net::HTTP).to receive(:Proxy).and_call_original
278278
expect(Net::HTTP).to receive(:start)
279279
.with('foo-uri', 443, connect_timeout: 10, open_timeout: 10, read_timeout: 10, use_ssl: true,
280-
ca_path: 'test-path').and_call_original
280+
ca_file: 'test-path').and_call_original
281281

282282
download_cache.get(uri_secure) {}
283283
end

0 commit comments

Comments
 (0)