如何告诉Ruby的OpenSSL库忽略自签名证书错误?
我尝试使用Ruby的SOAP支持,如下所示:
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
但是 new(SERVICE_URL)
的调用会被 SSL :: SSLError:certificate verify failed
。对于第一次调用WSDL的调用,我如何做相当于 driver.options ['protocol.http.ssl_config.verify_mode'] = OpenSSL :: SSL :: VERIFY_NONE
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?
我把一个名为 soap / property
在我的加载路径上,例如:
I put a file called "soap/property
" on my load path, e.g.:
- lib/
- foo.rb
- foo/
- bar.rb
- soap/
- property
将其放在文件中:
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
...