mirror of
https://github.com/rest-client/rest-client.git
synced 2022-11-09 13:49:40 -05:00
![Andy Brody](/assets/img/avatar_default.png)
The OpenSSL verify_callback isn't supported on jruby [1], and behaves in
somewhat surprising ways on OS X due to Apple monkey patching OpenSSL.
We probably want to move in the direction of just passing through the
OpenSSL exceptions anyway.
[1] https://github.com/jruby/jruby/issues/597
Fixes: #165
See also: #168, e03e5e6c
61 lines
1.9 KiB
Ruby
61 lines
1.9 KiB
Ruby
require 'spec_helper'
|
|
|
|
describe RestClient::Request do
|
|
before(:all) do
|
|
WebMock.disable!
|
|
end
|
|
|
|
after(:all) do
|
|
WebMock.enable!
|
|
end
|
|
|
|
describe "ssl verification" do
|
|
it "is successful with the correct ca_file" do
|
|
request = RestClient::Request.new(
|
|
:method => :get,
|
|
:url => 'https://www.mozilla.org',
|
|
:ssl_ca_file => File.join(File.dirname(__FILE__), "certs", "digicert.crt")
|
|
)
|
|
expect { request.execute }.to_not raise_error
|
|
end
|
|
|
|
it "is successful with the correct ca_path" do
|
|
request = RestClient::Request.new(
|
|
:method => :get,
|
|
:url => 'https://www.mozilla.org',
|
|
:ssl_ca_path => File.join(File.dirname(__FILE__), "capath_digicert")
|
|
)
|
|
expect { request.execute }.to_not raise_error
|
|
end
|
|
|
|
# TODO: deprecate and remove RestClient::SSLCertificateNotVerified and just
|
|
# pass through OpenSSL::SSL::SSLError directly. See note in
|
|
# lib/restclient/request.rb.
|
|
it "is unsuccessful with an incorrect ca_file" do
|
|
request = RestClient::Request.new(
|
|
:method => :get,
|
|
:url => 'https://www.mozilla.com',
|
|
:ssl_ca_file => File.join(File.dirname(__FILE__), "certs", "verisign.crt")
|
|
)
|
|
expect { request.execute }.to raise_error(RestClient::SSLCertificateNotVerified)
|
|
end
|
|
|
|
it "is unsuccessful with an incorrect ca_path" do
|
|
request = RestClient::Request.new(
|
|
:method => :get,
|
|
:url => 'https://www.mozilla.com',
|
|
:ssl_ca_path => File.join(File.dirname(__FILE__), "capath_verisign")
|
|
)
|
|
expect { request.execute }.to raise_error(RestClient::SSLCertificateNotVerified)
|
|
end
|
|
|
|
it "is successful using the default system cert store" do
|
|
request = RestClient::Request.new(
|
|
:method => :get,
|
|
:url => 'https://www.mozilla.org',
|
|
:verify_ssl => true,
|
|
)
|
|
expect {request.execute }.to_not raise_error
|
|
end
|
|
end
|
|
end
|