gpt4 book ai didi

ruby-on-rails - SSL错误 : hostname "W.X.Y.Z" does not match the server certificate

转载 作者:行者123 更新时间:2023-12-04 17:18:37 28 4
gpt4 key购买 nike

我刚开始学习 Ruby,在做了一些基本的事情之后,我试图理解在 ruby​​ 中对服务进行 REST 调用。我可以毫无问题地向foursquare API 发出get 请求。另一方面,对 Cisco CMX API 的调用会出错。我的 ruby 版本是 2.1.2。我在网上搜索了很多解决方案,但仍然有问题。这是我运行的 shell 命令。

工作一

$resclient
>> RestClient.get 'https://api.foursquare.com/v2/venues/search?ll=40.7,-74&oauth_token=0ZDO1JMJ0PW2QTCDK50OGZ21UENHZ0Y3KIDQZJLLURTQNRQ2&v=20150106'

这给出了错误
$restclient
>> RestClient.get 'https://learning:learning@64.103.26.61/api/contextaware/v1/maps/.json'

我的错误日志:
OpenSSL::SSL::SSLError: hostname "64.103.26.61" does not match the server certificate
from /Users/apple/.rbenv/versions/2.1.2/lib/ruby/2.1.0/openssl/ssl.rb:139:in `post_connection_check'
from /Users/apple/.rbenv/versions/2.1.2/lib/ruby/2.1.0/net/http.rb:922:in `connect'
from /Users/apple/.rbenv/versions/2.1.2/lib/ruby/2.1.0/net/http.rb:863:in `do_start'
from /Users/apple/.rbenv/versions/2.1.2/lib/ruby/2.1.0/net/http.rb:852:in `start'
from /Users/apple/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rest-client-1.7.2/lib/restclient/request.rb:413:in `transmit'
from /Users/apple/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rest-client-1.7.2/lib/restclient/request.rb:176:in `execute'
from /Users/apple/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rest-client-1.7.2/lib/restclient/request.rb:41:in `execute'
from /Users/apple/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rest-client-1.7.2/lib/restclient.rb:65:in `get'
from (irb):3
from /Users/apple/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rest-client-1.7.2/bin/restclient:93:in `<top (required)>'
from /Users/apple/.rbenv/versions/2.1.2/bin/restclient:23:in `load'
from /Users/apple/.rbenv/versions/2.1.2/bin/restclient:23:in `<main>'

你能给点建议吗?谢谢

最佳答案

一种几乎总是不好的解决方法是忽略 SSL 证书检查:

:verify_ssl => OpenSSL::SSL::VERIFY_NONE

更新:这种解决方法几乎永远不会被首选,因为它通常总结为一个容易忘记的明显安全漏洞。在大多数情况下,如果您认为不需要检查证书就需要 SSL,您最好生成一个自签名证书并锁定双方以使用相同的证书。

关于ruby-on-rails - SSL错误 : hostname "W.X.Y.Z" does not match the server certificate,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27795484/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com