SSL_connect(Errno :: ECONNRESET)

时间:2016-02-25 15:36:17

标签: ruby ssl rubygems cucumber

我们有基于黄瓜的UI自动化测试框架。最近我们已经从Ruby 1.9.x迁移到2.2.0,之后我们在通过测试框架登录我们的应用程序时遇到了问题。它说SSL连接重置问题。

错误追踪:

07:01:26 An existing connection was forcibly closed by the remote host. - SSL_connect (Errno::ECONNRESET)
07:01:26 D:/Ruby223/lib/ruby/gems/2.2.0/gems/httpclient-2.7.1/lib/httpclient/ssl_socket.rb:46:in `connect'
07:01:26 D:/Ruby223/lib/ruby/gems/2.2.0/gems/httpclient-2.7.1/lib/httpclient/ssl_socket.rb:46:in `ssl_connect'
07:01:26 D:/Ruby223/lib/ruby/gems/2.2.0/gems/httpclient-2.7.1/lib/httpclient/ssl_socket.rb:24:in `create_socket'
07:01:26 D:/Ruby223/lib/ruby/gems/2.2.0/gems/httpclient-2.7.1/lib/httpclient/session.rb:739:in `block in connect'
07:01:26 D:/Ruby223/lib/ruby/2.2.0/timeout.rb:88:in `block in timeout'
07:01:26 D:/Ruby223/lib/ruby/2.2.0/timeout.rb:98:in `call'
07:01:26 D:/Ruby223/lib/ruby/2.2.0/timeout.rb:98:in `timeout'
07:01:26 D:/Ruby223/lib/ruby/gems/2.2.0/gems/httpclient-2.7.1/lib/httpclient/session.rb:735:in `connect'
07:01:26 D:/Ruby223/lib/ruby/gems/2.2.0/gems/httpclient-2.7.1/lib/httpclient/session.rb:497:in `query'
07:01:26 D:/Ruby223/lib/ruby/gems/2.2.0/gems/httpclient-2.7.1/lib/httpclient/session.rb:170:in `query'
07:01:26 D:/Ruby223/lib/ruby/gems/2.2.0/gems/httpclient-2.7.1/lib/httpclient.rb:1238:in `do_get_block'
07:01:26 D:/Ruby223/lib/ruby/gems/2.2.0/gems/httpclient-2.7.1/lib/httpclient.rb:1021:in `block in do_request'
07:01:26 D:/Ruby223/lib/ruby/gems/2.2.0/gems/httpclient-2.7.1/lib/httpclient.rb:1129:in `protect_keep_alive_disconnected'
07:01:26 D:/Ruby223/lib/ruby/gems/2.2.0/gems/httpclient-2.7.1/lib/httpclient.rb:1016:in `do_request'
07:01:26 D:/Ruby223/lib/ruby/gems/2.2.0/gems/httpclient-2.7.1/lib/httpclient.rb:858:in `request'
07:01:26 D:/Ruby223/lib/ruby/gems/2.2.0/gems/httpclient-2.7.1/lib/httpclient.rb:761:in `post'
<-- our Code for login kick in to call httpclient --->
07:01:26 D:/Ruby223/lib/ruby/gems/2.2.0/gems/cucumber-2.3.2/lib/cucumber/rb_support/rb_language.rb:96:in `load'
07:01:26 D:/Ruby223/lib/ruby/gems/2.2.0/gems/cucumber-2.3.2/lib/cucumber/rb_support/rb_language.rb:96:in `load_code_file'
07:01:26 D:/Ruby223/lib/ruby/gems/2.2.0/gems/cucumber-2.3.2/lib/cucumber/runtime/support_code.rb:142:in `load_file'
07:01:26 D:/Ruby223/lib/ruby/gems/2.2.0/gems/cucumber-2.3.2/lib/cucumber/runtime/support_code.rb:84:in `block in load_files!'
07:01:26 D:/Ruby223/lib/ruby/gems/2.2.0/gems/cucumber-2.3.2/lib/cucumber/runtime/support_code.rb:83:in `each'
07:01:26 D:/Ruby223/lib/ruby/gems/2.2.0/gems/cucumber-2.3.2/lib/cucumber/runtime/support_code.rb:83:in `load_files!'
07:01:26 D:/Ruby223/lib/ruby/gems/2.2.0/gems/cucumber-2.3.2/lib/cucumber/runtime.rb:254:in `load_step_definitions'
07:01:26 D:/Ruby223/lib/ruby/gems/2.2.0/gems/cucumber-2.3.2/lib/cucumber/runtime.rb:62:in `run!'
07:01:26 D:/Ruby223/lib/ruby/gems/2.2.0/gems/cucumber-2.3.2/lib/cucumber/cli/main.rb:32:in `execute!'
07:01:26 D:/Ruby223/lib/ruby/gems/2.2.0/gems/cucumber-2.3.2/bin/cucumber:8:in `<top (required)>'

2 个答案:

答案 0 :(得分:0)

转移到ruby 2.0.0后,我有一段时间回答同样的问题

按照以下步骤解决问题

1)访问网址http://curl.haxx.se/ca/cacert.pem 将内容另存为.pem文件(不要将其另存为文本文件。请确保扩展名为.pem)

2)将文件复制到本地的任何路径,例如:C:\ ruby​​200 \ ca_cert.pem(在我的情况下)

3)现在添加一个环境变量,其变量为SSL_CERT_FILE,值为&#34; C:\ ruby​​200 \ ca_cert.pem&#34;(不带引号)(路径在我的例子中。具有适当路径的位置) (可以通过导航到计算机添加环境变量 - &gt;高级设置 - &gt;环境变量)

4)关闭所有命令提示并重新启动它们。现在应该可以正常工作

答案 1 :(得分:-1)

我认为您的gem已更新。在您的代码中添加这些行以解决问题

http.verify_mode = OpenSSL::SSL::VERIFY_NONE

之前http.use_ssl = true

我希望这可以解决问题。