Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pass global http request options to wasabi #349

Closed
rubiii opened this issue Dec 21, 2012 · 24 comments
Closed

pass global http request options to wasabi #349

rubiii opened this issue Dec 21, 2012 · 24 comments

Comments

@rubiii
Copy link
Contributor

rubiii commented Dec 21, 2012

currently, wasabi doesn't know about e.g. whether or not to verify ssl.
are there any other options we need to set to get the wsdl?

@arathunku
Copy link

Same problem when passing ssl_version

    client = Savon.client(wsdl: "https://webapi.allegro.pl/uploader.php?wsdl", ssl_version: :TLSv1)
    client.operations

D, [2012-12-30T18:04:12.476171 #390428] DEBUG -- : HTTPI GET request to webapi.allegro.pl (net_http)
C:/Ruby193/lib/ruby/gems/1.9.1/gems/httpi-2.0.0/lib/httpi/adapter/net_http.rb:36:in `rescue in request': SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (HTTPI::SSLError)
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/httpi-2.0.0/lib/httpi/adapter/net_http.rb:27:in `request'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/httpi-2.0.0/lib/httpi.rb:137:in `request'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/httpi-2.0.0/lib/httpi.rb:103:in `get'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/wasabi-3.0.0/lib/wasabi/resolver.rb:36:in `load_from_remote'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/wasabi-3.0.0/lib/wasabi/resolver.rb:26:in `resolve'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/wasabi-3.0.0/lib/wasabi/document.rb:113:in `xml'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/wasabi-3.0.0/lib/wasabi/document.rb:131:in `parse'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/wasabi-3.0.0/lib/wasabi/document.rb:118:in `parser'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/wasabi-3.0.0/lib/wasabi/document.rb:61:in `soap_actions'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/savon-2.0.2/lib/savon/client.rb:28:in `operations'
        from test.rb:7:in `<main>'

Could you provide temporary workaround?
I've found such workaround at stackoverflow

client.http.auth.ssl.verify_mode = :none

but that does not seem to work at 2.0.2

@rubiii
Copy link
Contributor Author

rubiii commented Dec 30, 2012

this is on top of my todo list right now. i'll try to come up with a fix by tomorrow.

@rubiii
Copy link
Contributor Author

rubiii commented Jan 1, 2013

this needs a bit more time to be fixed properly, but i'm working on it.

rubiii added a commit that referenced this issue Jan 6, 2013
Savon now uses the SOAPRequest and WSDLRequest factory classes to
create HTTPI requests for retrieving a remote WSDL document and for
executing SOAP requests.
@rubiii
Copy link
Contributor Author

rubiii commented Jan 6, 2013

both the global timeout and ssl options are now used for retrieving the wsdl.
could you please point your gemfile to master and test whether this works for you?

@arathunku
Copy link

Same problem;/

  client = Savon.client(wsdl: "https://webapi.allegro.pl/uploader.php?wsdl", ssl_verify_mode: :none, ssl_version: :TLSv1)  
  client.operations

Same error with and without ssl_version.

D, [2013-01-06T17:23:49.422232 #774096] DEBUG -- : HTTPI GET request to webapi.allegro.pl (net_http)
C:/Ruby193/lib/ruby/gems/1.9.1/gems/httpi-2.0.0/lib/httpi/adapter/net_http.rb:36:in `rescue in request': SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (HTTPI::SSLError)
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/httpi-2.0.0/lib/httpi/adapter/net_http.rb:27:in `request'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/httpi-2.0.0/lib/httpi.rb:137:in `request'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/httpi-2.0.0/lib/httpi.rb:103:in `get'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/wasabi-3.0.0/lib/wasabi/resolver.rb:36:in `load_from_remote'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/wasabi-3.0.0/lib/wasabi/resolver.rb:26:in `resolve'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/wasabi-3.0.0/lib/wasabi/document.rb:113:in `xml'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/wasabi-3.0.0/lib/wasabi/document.rb:131:in `parse'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/wasabi-3.0.0/lib/wasabi/document.rb:118:in `parser'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/wasabi-3.0.0/lib/wasabi/document.rb:61:in `soap_actions'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/savon-2.0.2/lib/savon/client.rb:28:in `operations'
        from test.rb:6:in `<main>'
Using savon (2.0.2) from git://github.com/savonrb/savon.git (at master)

@rubiii
Copy link
Contributor Author

rubiii commented Jan 7, 2013

client.rb:28:in 'operations' doesn't exist on master. could someone try again?
please ensure you're using master. thanks.

@arathunku
Copy link

D, [2013-01-07T16:12:45.126770 #28740] DEBUG -- : HTTPI GET request to webapi.allegro.pl (net_http)
C:/Ruby193/lib/ruby/gems/1.9.1/gems/httpi-2.0.0/lib/httpi/adapter/net_http.rb:36:in `rescue in request': SSL_connect returned=1 errno=0
state=SSLv3 read server certificate B: certificate verify failed (HTTPI::SSLError)
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/httpi-2.0.0/lib/httpi/adapter/net_http.rb:27:in `request'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/httpi-2.0.0/lib/httpi.rb:137:in `request'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/httpi-2.0.0/lib/httpi.rb:103:in `get'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/wasabi-3.0.0/lib/wasabi/resolver.rb:36:in `load_from_remote'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/wasabi-3.0.0/lib/wasabi/resolver.rb:26:in `resolve'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/wasabi-3.0.0/lib/wasabi/document.rb:113:in `xml'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/wasabi-3.0.0/lib/wasabi/document.rb:131:in `parse'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/wasabi-3.0.0/lib/wasabi/document.rb:118:in `parser'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/wasabi-3.0.0/lib/wasabi/document.rb:61:in `soap_actions'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/savon-2.0.2/lib/savon/operation.rb:19:in `ensure_exists!'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/savon-2.0.2/lib/savon/operation.rb:12:in `create'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/savon-2.0.2/lib/savon/client.rb:32:in `operation'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/savon-2.0.2/lib/savon/client.rb:36:in `call'
        from test.rb:7:in `<main>'
  client = Savon.client(wsdl: "https://webapi.allegro.pl/uploader.php?wsdl", ssl_verify_mode: :none, ssl_version: :TLSv1)  
  response = client.call(:doQuerySysStatus, 
                          message: {"sysver" => 1, 
                                    "country-id" => 1, 
                                    "webapi-key" => "WEBAPIKEY"} )

rubiii added a commit that referenced this issue Jan 7, 2013
@rubiii
Copy link
Contributor Author

rubiii commented Jan 7, 2013

@arathunku i added an example spec to the issue-349 branch and it passes!

i changed the operation name to snakecase, because the wsdl was properly retrieved
and the operation name didn't match the snakecase convention.

please try switching to a different HTTPI adapter like httpclient or curb to isolate the problem.

@arathunku
Copy link

That Sir, solved the problem! I'm really grateful, thank you!

@rubiii
Copy link
Contributor Author

rubiii commented Jan 7, 2013

you're welcome. may i ask what exactly fixed the problem for you?

@arathunku
Copy link

  require 'httpclient'
  HTTPI.adapter = :httpclient

Fixed the problem:)

@rubiii
Copy link
Contributor Author

rubiii commented Jan 7, 2013

oh noez 😢 so it seems like there is still an issue with net/http on windows.
maybe @matthewrobertson can confirm this?

@matthewrobertson
Copy link

net/http is working for me on OSX Mountain Lion. Sorry, I do not have access to a Windows machine to test with.

@rubiii
Copy link
Contributor Author

rubiii commented Jan 8, 2013

@matthewrobertson don't know why i thought you were running windows :)

@rubiii
Copy link
Contributor Author

rubiii commented Feb 3, 2013

http request options are passed to wasabi as of v2.1.0.

@rubiii rubiii closed this as completed Feb 3, 2013
@bwl21
Copy link

bwl21 commented Mar 31, 2013

It still seems not to work:

I am using savon 2.1.0 (on mac) and get

D, [2013-03-31T14:57:05.880672 #2440] DEBUG -- : HTTPI GET request to webservice.ad.local (httpclient)
at depth 0 - 20: unable to get local issuer certificate
/beweiche.rvm/gems/ruby-1.9.3-p374/gems/wasabi-3.0.0/lib/wasabi/resolver.rb:38:in `load_from_remote': #   <HTTPI::Response:0x007fa129da9e00> (Wasabi::Resolver::HTTPError)
from /u13.rvm/gems/ruby-1.9.3-p374/gems/wasabi-3.0.0/lib/wasabi/resolver.rb:26:in `resolve'
from /u13.rvm/gems/ruby-1.9.3-p374/gems/wasabi-3.0.0/lib/wasabi/document.rb:113:in `xml'
from /u13.rvm/gems/ruby-1.9.3-p374/gems/wasabi-3.0.0/lib/wasabi/document.rb:131:in `parse'
from /u13.rvm/gems/ruby-1.9.3-p374/gems/wasabi-3.0.0/lib/wasabi/document.rb:118:in `parser'
from /u13.rvm/gems/ruby-1.9.3-p374/gems/wasabi-3.0.0/lib/wasabi/document.rb:61:in `soap_actions'
from /u13.rvm/gems/ruby-1.9.3-p374/gems/savon-2.1.0/lib/savon/client.rb:30:in `operations'
from test_savon.rb:26:in `<main>'

using this piece of code

    require 'savon'
    require 'ruby-debug'

    config=YAML.load_file("bg_config.yaml")


    username=config[:username]
    password=config[:password]
    endpoint=config[:endpoint]

    client = Savon.client do
      ssl_verify_mode :none
      wsdl endpoint
      log  true
      log_level  :info
      pretty_print_xml true
    end

    puts client.operations

    response = client.call(:authenticate) do
      message :username => username, :password => password
      convert_request_keys_to :camelcase
    end

    debugger
    nil

@canario15
Copy link

I have de same problem:

client = Savon.client(ssl_verify_mode: :none) do
wsdl "#{wsdl_url}"
end

response = client.call(operation, :message => parameters)

HTTPI::SSLError: SSL_connect SYSCALL returned=5 errno=0 state=SSLv3 read server hello A
from /.rvm/gems/ruby-1.9.3-p392/gems/httpi-2.0.2/lib/httpi/adapter/httpclient.rb:28:in `rescue in request'

@rubiii
Copy link
Contributor Author

rubiii commented Apr 26, 2013

@bwl21 @vairix-gfagalde can you come up with a failing spec to reproduce the problem on travis?

@rubiii rubiii reopened this May 3, 2013
@bwl21
Copy link

bwl21 commented May 3, 2013

I found out that the problem is not the self signed certificate any more but the fact that authentification did not work

Maybe its worth to open an issue in wasabi to supply the response of the get request in case of failure.

@rubiii
Copy link
Contributor Author

rubiii commented May 5, 2013

@bwl21 if you have any suggestions on how to improve this, please feel free to open a new issue.

@rubiii
Copy link
Contributor Author

rubiii commented May 5, 2013

@vairix-gfagalde please follow up with further information or some example code to reproduce your problem.

@bwl21
Copy link

bwl21 commented May 5, 2013

First I thought this is simple. But then I found out, that wasabi cannot really help. The client needs to capture the exception and inform the user accordingly. As you are already sending the response as an error object, this can be done in the application.

But: if log_level in Savon is already set to debug, Savon could report e.g. the body of the failed response. I'll create an issue here.

@rubiii
Copy link
Contributor Author

rubiii commented Jul 1, 2013

closing this one. please follow up with a concrete plan to improve things or a pull request. thanks!

@rubiii rubiii closed this as completed Jul 1, 2013
@Gobol
Copy link

Gobol commented Sep 11, 2013

The problem may lie in outdated/invalid SSL certificates.
I've solved my problem on windows 7 x64 w/ ruby 2.0 + rails 4.0 following this page : https://gist.github.com/fnichol/867550

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

6 participants