Skip to content

Commit

Permalink
fixup ssl verify mode
Browse files Browse the repository at this point in the history
  • Loading branch information
tnaoto committed Jan 9, 2019
1 parent 607bbf8 commit 57e83f8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/octokit/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 11 additions & 0 deletions spec/octokit/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 57e83f8

Please sign in to comment.