ruby – RestClient.get返回证书验证失败
我正在使用RestClient和
Ruby v.2.2.1尝试使用内部测试API服务器.
这基本上是代码: url = "https://10.10.0.10/thing/i/want/to/get" header = { :content_type => "application/json",:"x-auth-token" => "testingtoken" } response = RestClient.get url,header 这是我收到的失败消息: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (RestClient::SSLCertificateNotVerified) 如果我正确阅读,看起来Ruby无法接受SSL安全证书.此调用适用于Chrome应用Postman,但为了使其正常工作,我必须点击Chrome本身的网址并接受连接不安全(但仍然继续),然后它将在邮递员中工作. 有没有办法忽略证书失败并继续在Ruby中继续? 解决方法
尝试使用#execute(& block),并将verify_ssl设置为false.
url = "https://10.10.0.10/thing/i/want/to/get" headers = { :content_type => "application/json",:"x-auth-token" => "testingtoken" } RestClient::Request.execute( :url => url,:method => :get,:headers => headers,:verify_ssl => false ) 见:http://www.rubydoc.info/github/rest-client/rest-client/RestClient/Request#execute-instance_method RVM RVM用户的其他解决方案来自:https://toadle.me/2015/04/16/fixing-failing-ssl-verification-with-rvm.html
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |