2010-07-03 07:30:06 -04:00
|
|
|
require File.join( File.dirname(File.expand_path(__FILE__)), '../base')
|
2010-05-13 12:56:56 -04:00
|
|
|
|
|
|
|
describe RestClient::Request do
|
|
|
|
describe "ssl verification" do
|
|
|
|
it "is successful with the correct ca_file" do
|
|
|
|
request = RestClient::Request.new(
|
|
|
|
:method => :get,
|
2011-08-15 05:01:43 -04:00
|
|
|
:url => 'https://www.mozilla.com',
|
2010-05-13 12:56:56 -04:00
|
|
|
:verify_ssl => OpenSSL::SSL::VERIFY_PEER,
|
2011-08-15 05:01:43 -04:00
|
|
|
:ssl_ca_file => File.join(File.dirname(__FILE__), "certs", "equifax.crt")
|
2010-05-13 12:56:56 -04:00
|
|
|
)
|
|
|
|
expect { request.execute }.to_not raise_error
|
|
|
|
end
|
|
|
|
|
2012-11-16 06:57:54 -05:00
|
|
|
# This doesn't works any more (under 1.9.3 at the very least). Exceptions in verify_callback are ignored.
|
|
|
|
# see https://github.com/ruby/ruby/blob/trunk/ext/openssl/ossl.c#L237
|
2010-05-13 12:56:56 -04:00
|
|
|
it "is unsuccessful with an incorrect ca_file" do
|
|
|
|
request = RestClient::Request.new(
|
|
|
|
:method => :get,
|
2011-08-15 05:01:43 -04:00
|
|
|
:url => 'https://www.mozilla.com',
|
2010-05-13 12:56:56 -04:00
|
|
|
:verify_ssl => OpenSSL::SSL::VERIFY_PEER,
|
2011-08-15 05:01:43 -04:00
|
|
|
:ssl_ca_file => File.join(File.dirname(__FILE__), "certs", "verisign.crt")
|
2010-05-13 12:56:56 -04:00
|
|
|
)
|
|
|
|
expect { request.execute }.to raise_error(RestClient::SSLCertificateNotVerified)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|