From 76c6b5283fb2d008d900766ea93ac339c142c3ae Mon Sep 17 00:00:00 2001 From: Bo Anderson Date: Mon, 4 Oct 2021 14:21:03 +0100 Subject: [PATCH] Use --insecure to download `ca-certificates` source where necessary --- Library/Homebrew/download_strategy.rb | 8 ++++++++ Library/Homebrew/resource.rb | 13 +++++++++++-- Library/Homebrew/software_spec.rb | 2 +- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb index 6af7a9669377ab..0441ac9ee2be4c 100644 --- a/Library/Homebrew/download_strategy.rb +++ b/Library/Homebrew/download_strategy.rb @@ -544,6 +544,14 @@ def _curl_args args += [meta[:header], meta[:headers]].flatten.compact.flat_map { |h| ["--header", h.strip] } + if meta[:insecure] + unless @insecure_warning_shown + opoo "Using --insecure with curl to download `ca-certificates` because we need it installed to download securely." + @insecure_warning_shown = true + end + args += ["--insecure"] if meta[:insecure] + end + args end diff --git a/Library/Homebrew/resource.rb b/Library/Homebrew/resource.rb index 23ccf9afe2d1fa..49d9e362a8fac4 100644 --- a/Library/Homebrew/resource.rb +++ b/Library/Homebrew/resource.rb @@ -42,6 +42,11 @@ def initialize(name = nil, &block) def owner=(owner) @owner = owner patches.each { |p| p.owner = owner } + + return if !owner.respond_to?(:full_name) || owner.full_name != "ca-certificates" + return if Homebrew::EnvConfig.no_insecure_redirect? + + @specs[:insecure] = !specs[:bottle] && !DevelopmentTools.ca_file_handles_most_https_certificates? end def downloader @@ -170,10 +175,14 @@ def sha256(val) def url(val = nil, **specs) return @url if val.nil? + specs = specs.dup + # Don't allow this to be set. + specs.delete(:insecure) + @url = val - @specs.merge!(specs) - @using = @specs.delete(:using) + @using = specs.delete(:using) @download_strategy = DownloadStrategyDetector.detect(url, using) + @specs.merge!(specs) @downloader = nil end diff --git a/Library/Homebrew/software_spec.rb b/Library/Homebrew/software_spec.rb index de44c202c3d356..3ef50b929fa864 100644 --- a/Library/Homebrew/software_spec.rb +++ b/Library/Homebrew/software_spec.rb @@ -310,8 +310,8 @@ def extname def initialize(formula, spec, tag = nil) @name = formula.name @resource = Resource.new - @resource.owner = formula @resource.specs[:bottle] = true + @resource.owner = formula @spec = spec tag_spec = spec.tag_specification_for(Utils::Bottles.tag(tag))