Skip to content

Commit

Permalink
Fixed cacert location (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
maxirmx authored May 15, 2024
1 parent 1f29e65 commit 771c13b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ namespace :build do
desc "Download cacert.pem"
task :download_cacert do
url = URI("https://curl.se/ca/cacert.pem")
FileUtils.mkdir_p("cert")
FileUtils.mkdir_p("lib/cert")
Net::HTTP.start(url.host, url.port, use_ssl: url.scheme == "https") do |http|
request = Net::HTTP::Get.new url
http.request request do |response|
open "cert/cacert.pem.mozilla", "w" do |io|
open "lib/cert/cacert.pem.mozilla", "w" do |io|
response.read_body do |chunk|
io.write chunk
end
Expand Down
5 changes: 4 additions & 1 deletion spec/runtime_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,9 @@ def tmpdir_name
end

it "provides an adapter for net/http gem" do
TebakoRuntime.send(:remove_const, :COMPILER_MEMFS)
TebakoRuntime::COMPILER_MEMFS = File.join(TebakoRuntime.full_gem_path("tebako-runtime"), "lib")

tfile = File.join(TebakoRuntime.full_gem_path("tebako-runtime"), "lib", "cert", "cacert.pem.mozilla")
expect(TebakoRuntime).to receive(:extract_memfs).with(tfile).and_call_original
require "net/http"
Expand All @@ -162,7 +165,7 @@ def tmpdir_name

http.use_ssl = true

expect(http.ca_file).to eq(tfile)
expect(http.ca_file).to eq(File.join(TebakoRuntime::COMPILER_MEMFS_LIB_CACHE, "cacert.pem.mozilla"))
expect(http.verify_mode).to eq(OpenSSL::SSL::VERIFY_PEER)
end

Expand Down

0 comments on commit 771c13b

Please sign in to comment.