使用 Shoes 并通过 https 下载会出现 ssl 错误
在鞋子应用程序中,我尝试从一些内部网站下载东西。 我收到此错误
Error in /tmp/selfgz14214/ruby/lib/net/protocol.rb line 66
undefined method 'closed?' for #<OpenSSL::SSL::SSLSocket:0xb6af94f0>
我收到此代码的上述错误。 如果从 Shoes 使用,则会出现上述错误。
require 'net/http'
require 'net/https'
require 'rexml/document'
class Blogs
attr_reader :Connection
def initialize
@Connection = Net::HTTP::new("someInternalWebSite", 443)
@Connection.use_ssl = true
end
def get_blogs
doc = REXML::Document.new @Connection.get('/weblogs/feed/entries/atom').body
blogs = Array.new
# ----- some crap to parse the blogs
return blogs
end
end
请注意,只有从鞋内跑步时才会出现此问题。
此外,在鞋子中使用内置的下载方法,它不会返回,甚至不会引发启动事件。 以下是该操作的代码
download "https://internalWebsite/weblogs/feed/entries/atom",
:start => lambda {
alert "hello"
},
:progress => lambda {
alert "progress"
},
:finish => lambda {
alert "finish"
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我没有使用过(或者确实听说过)鞋子,但是当我在 Ruby 中通过 HTTPS 访问内容时遇到问题,通常是因为没有正确设置证书。
我的经验是几年前的事了,但可能值得做一些实验来检查您是否确实可以使用该代码建立常规的 SSL 连接。 我希望您至少需要告诉它在哪里可以找到客户端证书,或者它根本不需要客户端证书。
我还记得我需要使用 http-access2 而不是常规的 http 库。
正如我所说,我确信自从我尝试这样做以来事情已经发生了变化,但我发现的大多数与 ssl 连接相关的问题都与证书相关。
I haven't worked with ( or indeed heard of ) shoes, but when I have had problems with accessing stuff over HTTPS in Ruby it has often been a case of not having the certificate set up properly.
My experience with this was a couple of years ago now but it may be worth doing a bit of experimentation just to check that you can actually make a regular SSL connection with that code. I would expect that you would at least need to tell it where to find the client certificate or that it doesn't need a client certificate at all.
I also recall that I needed to use http-access2 rather than the regular http library.
As I say, I'm sure things have moved on since I was trying to do this, but most of the problems I found relating to ssl connections were certificate related.
Shoes 当前版本不支持 HTTPS。
Shoes doesn't support HTTPS in the current version.