Skip to content

Commit

Permalink
feat: allow SSL verification to be disabled by setting environment va…
Browse files Browse the repository at this point in the history
…riable PACT_DISABLE_SSL_VERIFICATION=true
  • Loading branch information
bethesque committed Oct 1, 2021
1 parent 1c8d9fb commit dd39c04
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion lib/pact/consumer_contract/pact_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,13 @@ def prepare_request(uri, options)
http.use_ssl = (uri.scheme == 'https')
http.ca_file = ENV['SSL_CERT_FILE'] if ENV['SSL_CERT_FILE'] && ENV['SSL_CERT_FILE'] != ''
http.ca_path = ENV['SSL_CERT_DIR'] if ENV['SSL_CERT_DIR'] && ENV['SSL_CERT_DIR'] != ''
http.set_debug_output(Pact::Http::AuthorizationHeaderRedactor.new(Pact.configuration.output_stream)) if options[:verbose]
http.set_debug_output(Pact::Http::AuthorizationHeaderRedactor.new(Pact.configuration.output_stream)) if verbose?(options)
if disable_ssl_verification?
if verbose?(options)
Pact.configuration.output_stream.puts("SSL verification is disabled")
end
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
end
http
end

Expand Down Expand Up @@ -139,5 +145,13 @@ def delay_retry(count)
def windows_safe(uri)
uri.start_with?("http") ? uri : uri.gsub("\\", File::SEPARATOR)
end

def verbose?(options)
options[:verbose] || ENV['VERBOSE'] == 'true'
end

def disable_ssl_verification?
ENV['PACT_DISABLE_SSL_VERIFICATION'] == 'true' || ENV['PACT_BROKER_DISABLE_SSL_VERIFICATION'] == 'true'
end
end
end

0 comments on commit dd39c04

Please sign in to comment.