Created
January 19, 2012 23:48
-
-
Save zzak/1643808 to your computer and use it in GitHub Desktop.
why does mechanize hate me?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed | |
/home/zzak/.rvm/gems/ruby-1.9.3-p0@whatever/gems/net-http-persistent-2.3.3/lib/net/http/persistent/ssl_reuse.rb:70:in `connect' | |
/home/zzak/.rvm/gems/ruby-1.9.3-p0@whatever/gems/net-http-persistent-2.3.3/lib/net/http/persistent/ssl_reuse.rb:70:in `block in connect' | |
/home/zzak/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/timeout.rb:54:in `timeout' | |
/home/zzak/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/timeout.rb:99:in `timeout' | |
/home/zzak/.rvm/gems/ruby-1.9.3-p0@whatever/gems/net-http-persistent-2.3.3/lib/net/http/persistent/ssl_reuse.rb:70:in `connect' | |
/home/zzak/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/net/http.rb:755:in `do_start' | |
/home/zzak/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/net/http.rb:750:in `start' | |
/home/zzak/.rvm/gems/ruby-1.9.3-p0@whatever/gems/net-http-persistent-2.3.3/lib/net/http/persistent.rb:405:in `connection_for' | |
/home/zzak/.rvm/gems/ruby-1.9.3-p0@whatever/gems/net-http-persistent-2.3.3/lib/net/http/persistent.rb:616:in `request' | |
/home/zzak/.rvm/gems/ruby-1.9.3-p0@whatever/gems/mechanize-2.1/lib/mechanize/http/agent.rb:264:in `fetch' | |
/home/zzak/.rvm/gems/ruby-1.9.3-p0@whatever/gems/mechanize-2.1/lib/mechanize/http/agent.rb:853:in `response_redirect' | |
/home/zzak/.rvm/gems/ruby-1.9.3-p0@whatever/gems/mechanize-2.1/lib/mechanize/http/agent.rb:298:in `fetch' | |
/home/zzak/.rvm/gems/ruby-1.9.3-p0@whatever/gems/mechanize-2.1/lib/mechanize/http/agent.rb:853:in `response_redirect' | |
/home/zzak/.rvm/gems/ruby-1.9.3-p0@whatever/gems/mechanize-2.1/lib/mechanize/http/agent.rb:298:in `fetch' | |
/home/zzak/.rvm/gems/ruby-1.9.3-p0@whatever/gems/mechanize-2.1/lib/mechanize.rb:319:in `get' | |
/home/zzak/work/whatever/test/whatever/test_whatever.rb:15:in `block in test_something' | |
/home/zzak/.rvm/gems/ruby-1.9.3-p0@whatever/bundler/gems/vcr-11c8fb97ced4/lib/vcr/util/variable_args_block_caller.rb:9:in `call' | |
/home/zzak/.rvm/gems/ruby-1.9.3-p0@whatever/bundler/gems/vcr-11c8fb97ced4/lib/vcr/util/variable_args_block_caller.rb:9:in `call_block' | |
/home/zzak/.rvm/gems/ruby-1.9.3-p0@whatever/bundler/gems/vcr-11c8fb97ced4/lib/vcr.rb:142:in `use_cassette' | |
/home/zzak/work/whatever/test/whatever/test_whatever.rb:14:in `test_something' | |
/home/zzak/.rvm/gems/ruby-1.9.3-p0@whatever/gems/mocha-0.10.2/lib/mocha/integration/mini_test/version_230_to_262.rb:28:in `run' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'bundler/setup' | |
require 'fakeweb' | |
require 'mechanize' | |
require 'minitest/autorun' | |
require 'mocha' | |
require 'vcr' | |
VCR.configure { |c| | |
c.cassette_library_dir = 'fixtures/vcr_cassettes' | |
c.hook_into :fakeweb | |
} | |
class MyTest < MiniTest::Unit::TestCase | |
def setup | |
@agent = Mechanize.new | |
@agent.ca_file = '/usr/lib/ssl/certs/ca-certificates.crt' | |
@agent.verify_mode = OpenSSL::SSL::VERIFY_NONE | |
end | |
def test_something | |
VCR.use_cassette('something') do | |
form = @agent.get("http://whatever").forms[1] | |
assert_equal ["field1", "field2", "field3"],form.fields.collect(&:name) | |
end | |
end | |
end |
Are you trying to use it with VCR?
If so see drbrain/net-http-persistent#13
Nope, just writing a script that parses a local HTTPS site.
Try using Mechanize 2.0.x?
I tried using
agent.ca_file = ca_path
on OSX, ruby 1.9.3 with rvm and had no luck. (same SSL error)
Then, I changed it to
ca_path = File.expand_path "./cacert.pem"
agent.agent.http.ca_file = ca_path
and I was able to access the HTTPS site.
Works with 2.0.1, Thanks man.
Also, did you try master?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm having similar issues. Mechanize appears to be ignoring any changes to verify_mode as well as when I add a CA. Any luck?