0

For the below code got certificate verify failed (OpenSSL::SSL::SSLError) :

CODE

require 'mechanize'

agent = Mechanize.new

#{|a| a.ssl_version, a.verify_mode = 'SSLv3', OpenSSL::SSL::VERIFY_NONE}

agent.set_proxy('3.209.30.25', 80)
agent.ssl_version='SSLv3'
agent.verify_mode= OpenSSL::SSL::VERIFY_PEER

page = agent.get "https://gegsltraining.aravo.com/"

Error

C:/Ruby193/lib/ruby/gems/1.9.1/gems/net-http-persistent-2.8/lib/net/http/persist
ent/ssl_reuse.rb:70:in `connect': SSL_connect returned=1 errno=0 state=SSLv3 rea
d server certificate B: certificate verify failed (OpenSSL::SSL::SSLError)

EDIT

I just modified code as follows:

require 'mechanize'
agent = Mechanize.new
#{|a| a.ssl_version, a.verify_mode = 'SSLv3', OpenSSL::SSL::VERIFY_NONE}
agent.set_proxy('3.209.30.25', 80)
agent.ssl_version='SSLv3'
cert_store = OpenSSL::X509::Store.new
cert_store.add_file 'E:\WIPData\Ruby\Scripts\cacert.pem'
agent.cert_store = cert_store
agent.verify_mode= OpenSSL::SSL::VERIFY_PEER (tried OpenSSL::SSL::VERIFY_NONE none of them going good)

New Error

E:\WIPData\Ruby\Scripts>mechanizev1.rb
C:/Ruby193/lib/ruby/1.9.1/net/http.rb:2632:in `error!': 500 "Internal Server Err
or" (Net::HTTPFatalError)

How to be done that certification verification successfully? help me.

Arup Rakshit
  • 116,827
  • 30
  • 260
  • 317
  • Please help me here, my code got stuck due to the issue! – Arup Rakshit Jan 23 '13 at 08:38
  • 1
    You seem to be having many problems with the most basic concepts. Have you considered hiring someone to help you? – pguardiario Jan 23 '13 at 11:08
  • I thought the community can be a good option,where I can have multiple people who has faced the same issue. He might be helpful for me. Because these are really some serious problems,for which none of the code runs. – Arup Rakshit Jan 23 '13 at 11:55
  • +1 @pguardiario, Not only many basic problems, but I suspect under multiple personalities too. – the Tin Man Jan 23 '13 at 15:36

1 Answers1

0

Just set your mechanize agent object.http.ca_file to point to this file.

agent.agent.http.ca_file = '/etc/ssl/certs/curl-ca-bundle.crt'

Otherway to do this, is to save the curl-ca-bundle.crt in app lib directory and then set

agent.agent.http.ca_file = 'lib/curl-ca-bundle.crt'