Skip to content

Commit bf1333d

Browse files
authored
feat: use certificates from SSL_CERT_FILE and SSL_CERT_DIR environment variables in HTTP connections
1 parent b8e44df commit bf1333d

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/pact/consumer_contract/pact_file.rb

+5-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,11 @@ def get_remote(uri, options)
8181
request = Net::HTTP::Get.new(uri)
8282
request.basic_auth(options[:username], options[:password]) if options[:username]
8383
request['Authorization'] = "Bearer #{options[:token]}" if options[:token]
84-
Net::HTTP.start(uri.host, uri.port, :ENV, use_ssl: uri.scheme == 'https') do |http|
84+
http = Net::HTTP.new(uri.host, uri.port, :ENV)
85+
http.use_ssl = (uri.scheme == 'https')
86+
http.ca_file = ENV['SSL_CERT_FILE'] if ENV['SSL_CERT_FILE'] && ENV['SSL_CERT_FILE'] != ''
87+
http.ca_path = ENV['SSL_CERT_DIR'] if ENV['SSL_CERT_DIR'] && ENV['SSL_CERT_DIR'] != ''
88+
http.start do |http|
8589
http.open_timeout = options[:open_timeout] || OPEN_TIMEOUT
8690
http.read_timeout = options[:read_timeout] || READ_TIMEOUT
8791
http.request(request)

0 commit comments

Comments
 (0)