views:

771

answers:

2

I'm trying to use Ruby's SOAP support as follows:

SERVICE_URL = 'https://...'
...
def create_driver
  ::SOAP::WSDLDriverFactory.new(SERVICE_URL).create_rpc_driver
  driver.options['protocol.http.ssl_config.verify_mode']  = OpenSSL::SSL::VERIFY_NONE
  driver.options['protocol.http.ssl_config.client_cert']  = @certificate_path
  driver
end

but the call to new(SERVICE_URL) blows up with "OpenSSL::SSL::SSLError: certificate verify failed." How do I do the equivalent of driver.options['protocol.http.ssl_config.verify_mode'] = OpenSSL::SSL::VERIFY_NONE for the first call to retrieve the WSDL itself?

A: 

try this:

...
  OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
  ::SOAP::WSDLDriverFactory.new(SERVICE_URL).create_rpc_driver
...
avguchenko
You're saying I redefine `VERIFY_PEER` to be the value of `VERIFY_NONE`? That's risky since I can't be certain whether the code for checking the verification method checks for the value of VERIFY_NONE or VERIFY_PEER. Redefining constants is an absolute last resort.
James A. Rosen
thanks Gaius. it is pretty sneaky, you're right.
avguchenko
I should say, though, that it *will* work. It may be a last resort because it's sneaky, but if all else fails...
James A. Rosen
+2  A: 

I put a file called "soap/property" on my load path, e.g.:

- lib/
    - foo.rb
    - foo/
        - bar.rb
    - soap/
        - property

And put this in the file:

client.protocol.http.ssl_config.verify_mode = OpenSSL::SSL::VERIFY_NONE

Alternatively, if you have multiple settings with the same prefix, you can use the group syntax:

[client.protocol.http]
ssl_config.verify_mode = OpenSSL::SSL::VERIFY_NONE
...
James A. Rosen