Skip to content

Commit

Permalink
Fix ssl_client_cert and ssl_client_key (lostisland#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
karissekjw committed Jul 6, 2023
1 parent f85dbc1 commit 8aca980
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/faraday/http/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

module Faraday
module Http
VERSION = '2.0.0'
VERSION = '2.0.1'
end
end
31 changes: 31 additions & 0 deletions spec/faraday/http/adapter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,35 @@
end.to raise_error(Faraday::SSLError, 'foo')
end
end

context 'when client certificate and private key are provided' do
let(:conn) do
conn_options[:ssl] ||= {}
conn_options[:ssl][:client_cert] ||= OpenSSL::X509::Certificate.new
conn_options[:ssl][:private_key] ||= OpenSSL::PKey::RSA.new

Faraday.new(remote, conn_options) do |conn|
conn.request :url_encoded
conn.response :raise_error
conn.adapter described_class, *adapter_options
end
end

subject { conn.get('/', nil, { user_agent: 'Agent Faraday' }) }

it 'makes a request successfully' do
stub_request(:get, 'https://example.com/')
.with(
headers: {
'Connection' => 'close',
'Host' => 'example.com',
'User-Agent' => 'Agent Faraday',
'X-Faraday-Adapter' => 'HTTP'
}
)
.to_return(status: 200, body: '', headers: {})

expect(subject).to be_success
end
end
end

0 comments on commit 8aca980

Please sign in to comment.