由于我正在为我的 RoR3 应用程序开发“安全”OAuth 协议,因此我需要通过 Internet 发送受保护的信息,因此我需要使用 HTTPS 连接 (SSL/TSL)。我读过 如何治愈 Net::HTTP有风险的默认 HTTPS 行为 文章提到了 'always_verify_ssl_certificates' gem,但是,因为我想尽可能更加“纯粹”(这意味着:我不想安装其他 gem,但我尝试使用 Ruby on Rails 做所有事情),我想在不安装新 gem 的情况下完成这项工作。
我读到了有关“open_uri”的内容(链接文章:“open_uri 是一个常见的例外 - 它使事情正确!”)来自 Ruby OOPL,我认为它可以完成相同的工作。
那么,对于我的需求,“open_uri”是最好的选择吗(尽管它比“always_verify_ssl_certificates”gem更复杂)?如果是这样,有人可以帮助我使用它(如果可能的话,举个例子),因为我还没有找到好的指南?
Since I am developing a "secure" OAuth protocol for my RoR3 apps, I need to send protected information over the internet, so I need to use HTTPS connections (SSL/TSL). I read How to Cure Net::HTTP’s Risky Default HTTPS Behavior aticle that mentions the 'always_verify_ssl_certificates' gem, but, since I want to be more "pure" (it means: I do not want to install other gems, but I try to do everything with Ruby on Rails) as possible, I want to do that work without installing new gems.
I read about 'open_uri' (it is also mentioned in the linked article: "open_uri is a common exception - it gets things right!") that is from the Ruby OOPL and I think it can do the same work.
So, for my needs, is 'open_uri' the best choice (although it is more complicated of 'always_verify_ssl_certificates' gem)? If so, can someone help me using that (with an example, if possible) because I have not found good guides about?
发布评论
评论(1)
您应该找到最适合该工作的工具并使用它。您不应该尝试将库的使用仅限于 Rails 和 Ruby 标准库,因为仅靠这两个库并不总能为您提供所需的一切。正如您所指出的,您找到了适合这项工作的正确工具 - 不要仅仅因为它不是“官方”Ruby 或 Rails 的一部分而拒绝它。
您可以使用 Bundler 轻松管理您的应用程序需要哪些 gem,这样团队中的每个人都可以通过一个命令始终能够安装并运行应用程序,包括自动安装所有 gem 依赖项。默认情况下,Rails 3 与 Bundler 集成,并希望您使用 Bundler 来管理所有 gem 依赖项。
You should find the best tool for the job and use it. You should not try to limit your usage of libraries to just Rails and the Ruby standard library, because these two alone will not always provide you with everything you need. As you have indicated, you found the right tool for the job - don't reject it just because it's not part of "official" Ruby or Rails.
You can easily manage which gems your application needs with Bundler, such that everyone on the team is, with a single command, always able to install and run the application, including automatically installing all gem dependencies. Rails 3, by default, integrates with Bundler and expects that you will use Bundler to manage all your gem dependencies.