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

Ability to modify SSL options #297

Closed
rslifka opened this issue Jun 15, 2012 · 24 comments
Closed

Ability to modify SSL options #297

rslifka opened this issue Jun 15, 2012 · 24 comments

Comments

@rslifka
Copy link

rslifka commented Jun 15, 2012

Hi there,

In upgrading to Savon 1.0, we can no longer attach to HTTPS endpoints as it appears certification verification is now required. We would like to disable verification via something akin to:

http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

However, there is no way to communicate from Savon > HTTPI > Net::HTTP as the only form of communication appears to be string based (i.e. the 'request' variable is all thats passed from Savon::Client.new all the way down to Net::HTTP).

Thanks!

Rob

@hoverlover
Copy link
Contributor

Could you please show how you are initializing your Savon client? Thanks.

@rslifka
Copy link
Author

rslifka commented Jun 16, 2012

@client = Savon::Client.new('https://pantherportal.cdnetworks.com/wsdl/flush.wsdl')

The HTTP version of that endpoint redirects to that endpoint. Unfortunately no choice there.

@rubiii
Copy link
Contributor

rubiii commented Jun 16, 2012

shouldn't this be possible?

client.http.ssl.verify_mode = :none

do you have configuraton like this?

@rubiii
Copy link
Contributor

rubiii commented Jun 28, 2012

@rslifka should we follow up on this?

@rslifka
Copy link
Author

rslifka commented Jun 29, 2012

Thanks for following up! We'll take another crack at updating the gem and report back. Sorry, not sure where my GitHub notifications are going.

@kashivreddy
Copy link

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

@rubiii
Copy link
Contributor

rubiii commented Sep 4, 2012

@rslifka can you confirm?

@vaibhavbansal
Copy link

We are facing a weird problem we are trying to hit a https end point and when we use client.http.auth.ssl.verify_mode = :none savon makes a call to the http end point. Is there a way of hitting the https end point and ignoring the certificate error

@rubiii
Copy link
Contributor

rubiii commented Sep 4, 2012

@vaibhavbansal please open a new issue and post a spec and/or an example and the wsdl somewhere for me to debug.

@rslifka
Copy link
Author

rslifka commented Sep 6, 2012

Hi Daniel,

Apologies I've been swamped and haven't verified this. Making any call to the endpoint (even retrieving the list of services I imagine) would verify that it worked. I'll have a look, might be a few days though.

@maqen
Copy link

maqen commented Sep 18, 2012

Even with client.http.auth.ssl.verify_mode = :none I get error

SSL_connect returned=1 errno=0 state=SSLv2/v3 read server hello A: sslv3 alert unexpected message

@kazmin
Copy link

kazmin commented Oct 5, 2012

me too!

@rubiii
Copy link
Contributor

rubiii commented Oct 8, 2012

unfortunately "me too" doesn't help. i need a way to reproduce the problem.
i'd appreciate any support.

@maqen
Copy link

maqen commented Oct 8, 2012

SSL_connect returned=1 errno=0 state=SSLv2/v3 read server hello A: sslv3 alert unexpected message

The problem is that you have to explicit set the ssl version to use. The error above is generated when version 3 (SSLv3) is used.

I've found a fork of httpi by @nicdal (http://github.com/nicdal/httpi.git) that allowed me to set the ssl version together with Savon (1.2.0)

@client = Savon::Client.new do
    wsdl.document = WSDL_URL
    http.auth.ssl.verify_mode = :none
    http.auth.ssl.ssl_version = :SSLv3
end

This solved my error without any other code modifications.

@rubiii
Copy link
Contributor

rubiii commented Oct 9, 2012

thank you very much @maqen. i'll have a look into it.

@rubiii
Copy link
Contributor

rubiii commented Dec 10, 2012

[support for specifying the soap version]((savonrb/httpi@b32fd49) was added in httpi v2.0.0.rc1.
not sure when savon will support this version yet.

@garcialopezco
Copy link

In new version v2.0.0, how can I disable ssl verification ( http.auth.ssl.verify_mode = :none ) ??

@rubiii rubiii closed this as completed in cd94583 Dec 19, 2012
@rubiii
Copy link
Contributor

rubiii commented Dec 19, 2012

@carlos-logicalbricks just realized that this was missing. it added an option for this on master.
please give it a try. i'll release this soon.

@garcialopezco
Copy link

Thanks a lot!!

@rubiii
Copy link
Contributor

rubiii commented Dec 19, 2012

thanks for spotting this. i updated the documentation for more information about this.

@bjm88
Copy link

bjm88 commented Apr 7, 2015

Hi - we have a situation with a test SOAP service where we need to use SSL cert and private key to present via client auth from server, however the actual HTTPS hosted cert the domain has is self signed or not valid, host verification wise. So we want to not verify them, host domain wise, but still present our cert and private key for client auth.....Does Savon support this?

We are having issues when we set ssl_verify_mode: :none
we'll get this error...
HTTPI GET request to wir.dhswir.org (net_http)
HTTPI::SSLError: SSL_read: ssl handshake failure
from /Users/Ben/.rvm/gems/ruby-2.1.5@caredox/gems/httpi-2.0.2/lib/httpi/adapter/net_http.rb:36:in `rescue in request'

if we remove ssl_verify_mode: :none,, then it works...here is the rest of the client initialization. To test after that we do client.operations

client = Savon.client(log_level: :debug,
log: true,
filters: [:password],
ssl_cert_file: (Rails.root + 'signed.cer').to_s,
ssl_cert_key_file: ('private.key').to_s,
env_namespace: :soap,
namespace_identifier: :urn,
namespace: 'urn:cdc:iisb:2011',
soap_version: 2,
wsdl: "https://example.com/Service?wsdl",
endpoint: "https://example.com/Service",
open_timeout: 30,
read_timeout: 30)

Also note bc/ of this reported issue in 2.3.0 savon we are using 2.2.0

#491

ANy ideas?

@noahmatisoff
Copy link

+1 I'm having this error as well. Trying to connect to a WSDL service using Savon on Ruby 2.1.4 and Savon 2.10.0 and I'm getting this error. Have tried setting ssl_verify_mode to no avail.

@aledustet
Copy link

I can connect using the Net::HTTP library adding a custom certificate like this:

http = Net::HTTP.new(host, port)
http.use_ssl = true
http.cert_store = OpenSSL::X509::Store.new
http.cert_store.set_default_paths
raw = File.read('cert_path')
certificate = OpenSSL::X509::Certificate.new raw
http.cert_store.add_cert certificate

This connection succeeds. Is there anyway to set the cert_store on the excon or the http connection savon is gonna make?

@KelseyDH
Copy link

KelseyDH commented Nov 13, 2019

Annoyingly it's not in the documentation, but Savon supports ssl_cert and ssl_cert_key as options, so you don't have to use a ssl_cert_file / ssl_cert_key_file like the docs suggest.

This will work:

      Savon.client(
        # . . .
        ssl_cert: OpenSSL::X509::Certificate.new( ENV["SSL_CERT"] ),
        ssl_cert_key: OpenSSL::PKey::RSA.new( ENV["SSL_CERT_KEY"] )
      )

and if your ssl_cert_key is locked with a password, unlock it with your ENV variables like this:

ssl_cert_key: OpenSSL::PKey::RSA.new( ENV["SSL_CERT_KEY"], ENV["SSL_CERT_KEY_PASSWORD"])

It would be great if the Savon docs were updated to include these two options for SSL.

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