tags:

views:

1578

answers:

4
+1  Q: 

Ruby SOAP SSL Woes

I have a SOAP client in Ruby that I'm trying to get working with a Ruby SOAP server, to no avail. The client works fine over SSL with a Python SOAP server, but not with the Ruby version. Here's what the server looks like:

require 'soap/rpc/standaloneServer'
require 'soap/rpc/driver'
require 'rubygems'
require 'httpclient'

def cert(filename)
  OpenSSL::X509::Certificate.new(File.open("path to cert.cert") { |f|
    f.read
  })
end

def key(filename)
  OpenSSL::PKey::RSA.new(File.open("path to rsaprivate.key") { |f|
    f.read
  })
end

class Server < SOAP::RPC::HTTPServer
 ~code snipped for readability~
end

server = Server.new(:BindAddress => HelperFunctions.local_ip, :Port => 1234, :SSLCertificate => cert("path to cert"), :SSLPrivateKey => key("path to rsa private key"))
new_thread = Thread.new { server.start }

I've trimmed some of the code out for readability's sake (e.g., I have some methods in there I expose) and it works fine with SSL off. But when the client tries to connect, it sees this:

warning: peer certificate won't be verified in this SSL session
/usr/lib/ruby/1.8/net/http.rb:567: warning: using default DH parameters.
/usr/lib/ruby/1.8/net/http.rb:586:in `connect': unknown protocol (OpenSSL::SSL::SSLError)

I tried taking some advice from this post and now I see this message:

/usr/lib/ruby/1.8/soap/httpconfigloader.rb:64:in `set_ssl_config': SSL not supported (NotImplementedError)

Any ideas on how to fix this would be greatly appreciated.

+2  A: 

Arg. I was trying to follow along this link and it turns out I was missing a simple include statement:

require 'webrick/https'

That, combined with the help from the link in the original question solves the problem. Hopefully this saves someone else down the line an hour of grief :)

Chris Bunch
A: 

Me too.. and don't forget to put the :SSLEnable => true spend couple of hours figuring that out...

server = Server.new(:BindAddress => HelperFunctions.local_ip, :Port => 1234, :SSLEnable => true, :SSLCertificate => cert("path to cert"), :SSLPrivateKey => key("path to rsa private key"))
A: 

"SSL not supported" can be caused by not having httpclient installed.

Brad Whitaker
A: 

I have a

/usr/lib/ruby/1.8/soap/httpconfigloader.rb:64:in `set_ssl_config': SSL not supported (NotImplementedError)

error, too.

httpclient is installed, 'webrick/https' is required in the soap server and :SSLEnable => true is set.

Any other ideas?

Ben