How do I tell Ruby's OpenSSL library to ignore a self-signed certificate error?

certificate, openssl, ruby, soap, wsdl

Solution

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
...

Problem

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?

Original source