Skip to content

Commit

Permalink
adds missing support for cert password
Browse files Browse the repository at this point in the history
  • Loading branch information
Bryce Kwan committed Apr 28, 2016
1 parent 55f15e1 commit caf68fe
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/httpi/adapter/curb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ def setup_ssl_auth
# Send client-side certificate regardless of state of SSL verify mode
@client.cert_key = ssl.cert_key_file
@client.cert = ssl.cert_file
@client.certpassword = ssl.cert_key_password

@client.ssl_verify_peer = ssl.verify_mode == :peer
end
Expand Down
5 changes: 4 additions & 1 deletion spec/httpi/adapter/curb_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
it "supports ntlm authentication" do
request = HTTPI::Request.new(@server.url + "ntlm-auth")
adapter = HTTPI::Adapter::Curb.new(request)

request.auth.ntlm("tester", "vReqSoafRe5O")
expect(adapter.request(:get).body).to eq("ntlm-auth")
end
Expand Down Expand Up @@ -279,6 +279,7 @@
request = HTTPI::Request.new("http://example.com")
request.auth.ssl.cert_key_file = "spec/fixtures/client_key.pem"
request.auth.ssl.cert_file = "spec/fixtures/client_cert.pem"
request.auth.ssl.cert_key_password = 'example'
request
end

Expand All @@ -287,13 +288,15 @@
curb.expects(:ssl_verify_host=).with(0) # avoid "SSL peer certificate" error
curb.expects(:cert_key=).with(request.auth.ssl.cert_key_file)
curb.expects(:cert=).with(request.auth.ssl.cert_file)
curb.expects(:certpassword=).with(request.auth.ssl.cert_key_password)

adapter.request(:get)
end

it "cert_key, cert and ssl_verify_peer should be set" do
curb.expects(:cert_key=).with(request.auth.ssl.cert_key_file)
curb.expects(:cert=).with(request.auth.ssl.cert_file)
curb.expects(:certpassword=).with(request.auth.ssl.cert_key_password)
curb.expects(:ssl_verify_peer=).with(true)
curb.expects(:certtype=).with(request.auth.ssl.cert_type.to_s.upcase)

Expand Down

0 comments on commit caf68fe

Please sign in to comment.