首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ruby jiraSOAP net-http ssl验证

ruby jiraSOAP net-http ssl验证
EN

Stack Overflow用户
提问于 2011-12-08 00:33:02
回答 1查看 502关注 0票数 3

通过Handsoap和jiraSOAP加载时,如何指定net/http不验证SSL证书。请看下面的代码:

代码语言:javascript
复制
require 'jiraSOAP'

Handsoap.http_driver = :net_http

api = JIRA::JIRAService.new jira_url
api.login(jira_user,jira_pwd)

我知道我需要这个:OpenSSL::SSL::VERIFY_NONE

以下错误:

代码语言:javascript
复制
OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed
    from /usr/local/lib/ruby/1.9.1/net/http.rb:678:in `connect'
    from /usr/local/lib/ruby/1.9.1/net/http.rb:678:in `block in connect'
    from /usr/local/lib/ruby/1.9.1/timeout.rb:58:in `timeout'
    from /usr/local/lib/ruby/1.9.1/timeout.rb:89:in `timeout'
    from /usr/local/lib/ruby/1.9.1/net/http.rb:678:in `connect'
    from /usr/local/lib/ruby/1.9.1/net/http.rb:637:in `do_start'
    from /usr/local/lib/ruby/1.9.1/net/http.rb:626:in `start'
    from /usr/local/lib/ruby/gems/1.9.1/gems/handsoap-1.1.8/lib/handsoap/http/drivers/net_http_driver.rb:53:in `send_http_request'
    from /usr/local/lib/ruby/gems/1.9.1/gems/handsoap-1.1.8/lib/handsoap/service.rb:249:in `invoke'
    from /usr/local/lib/ruby/gems/1.9.1/gems/jiraSOAP-0.10.3/lib/jiraSOAP/api.rb:55:in `build'
    from /usr/local/lib/ruby/gems/1.9.1/gems/jiraSOAP-0.10.3/lib/jiraSOAP/api.rb:69:in `soap_call'
    from /usr/local/lib/ruby/gems/1.9.1/gems/jiraSOAP-0.10.3/lib/jiraSOAP/api.rb:18:in `login'
EN

回答 1

Stack Overflow用户

发布于 2012-03-20 09:38:50

我在使用HandSoap 1.1.8时也遇到了同样的问题。注意到NetHttpDriver引用了没有根作用域的Net::Http,所以我能够比较简洁地覆盖它。

代码语言:javascript
复制
class SoapService < ::Handsoap::Service

  def http_driver_instance
    Handsoap::Http.drivers[:net_http].new
  end

  # This is rather ugly. Handsoap provides no hooks in its drivers to allow certs to be ignored.
  # Luckily, it calls Net::Http without the root scope, so we can shoehorn it.
  require 'handsoap/http/drivers/net_http_driver'
  require 'net/http'
  module Handsoap::Http::Drivers
    class NetHttpDriver
      module Net
        class HTTP < ::Net::HTTP
          def initialize(address, port = nil)
            super
            self.verify_mode = OpenSSL::SSL::VERIFY_NONE
          end
        end
      end
    end
  end

end
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/8418893

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档