2011-12-07 63 views
3

我怎樣才能通過Handsoap和jiraSOAP時加載指定網/ HTTP不驗證SSL證書..請參見下面的代碼:紅寶石jiraSOAP淨HTTP SSL驗證

require 'jiraSOAP' 

Handsoap.http_driver = :net_http 

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

我知道我需要這個地方:OpenSSL::SSL::VERIFY_NONE

錯誤如下:

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' 
+0

我做了一個黑客在/usr/local/lib/ruby/gems/1.9.1/gems/handsoap-1.1.8/lib/handsoap/http/drivers/net_http_driver.rb:39並補充說: http_client.verify_mode = OpenSSL :: SSL :: VERIFY_NONE,但這是不正確的。 – nictrix

+0

嘿尼克 - 你能成功解決這個問題嗎?我也有同樣的問題。我的1.9.1無法驗證JIRA的證書。沒有很多人知道這個問題。 –

回答

1

我有同樣的問題,使用HandSoap 1.1.8。注意到NetHttpDriver在沒有根作用域的情況下引用Net :: Http,所以我能夠稍微簡潔地覆蓋它。

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