diff --git a/lib/octokit/connection.rb b/lib/octokit/connection.rb index a94344063..791bc2315 100644 --- a/lib/octokit/connection.rb +++ b/lib/octokit/connection.rb @@ -175,7 +175,15 @@ def sawyer_options conn_opts = @connection_options conn_opts[:builder] = @middleware if @middleware conn_opts[:proxy] = @proxy if @proxy - conn_opts[:ssl] = { :verify_mode => @ssl_verify_mode } if @ssl_verify_mode + if conn_opts[:ssl].nil? + conn_opts[:ssl] = { :verify_mode => @ssl_verify_mode } if @ssl_verify_mode + else + if @connection_options[:ssl][:verify] == false + conn_opts[:ssl] = { :verify_mode => 0} + else + conn_opts[:ssl] = { :verify_mode => @ssl_verify_mode } + end + end opts[:faraday] = Faraday.new(conn_opts) opts diff --git a/spec/octokit/client_spec.rb b/spec/octokit/client_spec.rb index 3d4c26de3..931a283c0 100644 --- a/spec/octokit/client_spec.rb +++ b/spec/octokit/client_spec.rb @@ -421,6 +421,17 @@ conn = Octokit.client.send(:agent).instance_variable_get(:"@conn") expect(conn.proxy[:uri].to_s).to eq('http://proxy.example.com') end + it "no sets an ssl verify" do + client = Octokit::Client.new + expect(client.connection_options[:ssl]).to be nil + end + it "sets an ssl verify => false" do + client = Octokit::Client.new( + :connection_options => {:ssl => {:verify => false}} + ) + conn = client.send(:agent).instance_variable_get(:"@conn") + expect(conn.ssl[:verify_mode]).to eq(OpenSSL::SSL::VERIFY_NONE) + end it "sets an ssl verify mode" do Octokit.configure do |config| config.ssl_verify_mode = OpenSSL::SSL::VERIFY_NONE