如何告诉Ruby的OpenSSL库忽略自签名证书错误? [英] How do I tell Ruby's OpenSSL library to ignore a self-signed certificate error?

查看:447
本文介绍了如何告诉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
...

这篇关于如何告诉Ruby的OpenSSL库忽略自签名证书错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆