是否可以在 Ruby 中启用 TLS v1.2?如果是这样,如何?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11059059/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Is it possible to enable TLS v1.2 in Ruby? If so, how?
提问by lcarpenter
Is it possible to use TLSv.1.2 or TLSv1.1 with Ruby?
是否可以在 Ruby 中使用 TLSv.1.2 或 TLSv1.1?
I have compiled a Frankenstein version of Ruby using OpenSSL 1.0.1c (the latest available) and the only difference being is SSLv2 is now an option under OpenSSL::SSL::SSLContext::METHODS
我已经使用 OpenSSL 1.0.1c(最新可用的)编译了一个 Frankenstein 版本的 Ruby,唯一的区别是 SSLv2 现在是一个选项 OpenSSL::SSL::SSLContext::METHODS
Is it possible to add TLSv1.2 to that list?
是否可以将 TLSv1.2 添加到该列表中?
回答by emboss
Yes, we added TLS 1.1 & 1.2 support recently. It's as easy as setting ssl_versionon your SSLContext:
是的,我们最近添加了 TLS 1.1 和 1.2 支持。这就像ssl_version在您的设置上一样简单SSLContext:
ctx = OpenSSL::SSL::SSLContext.new
ctx.ssl_version = :TLSv1_2
You may still continue to use the more generic :SSLv23for maximum interoperability. It will have the effect that the newest protocol supported by the peer will be used for the connection. If your peer understands TLS 1.2, then it will be used. But opposed to the above sample, if the peer does not speak 1.2, then the implementation will silently fall back to the best/newest version that the peer doesunderstand - while in the above example, the connection would be rejected by the peer if it did not recognize 1.2.
您仍然可以继续使用更通用的:SSLv23以实现最大的互操作性。这将产生对等方支持的最新协议将用于连接的效果。如果您的对等方理解 TLS 1.2,则将使用它。但是,相对于上面的示例,如果对方不说话1.2,然后实施将无声地回落到最佳/最新版本,同行不理解-而在上面的例子中,连接将由如果对方拒绝不认识 1.2。
For further details, also have a look at OpenSSL's own docson the subject, you can transfer what's being said about TLSv1_method to TLSv1_1_method and TLSv1_2_method (represented in Ruby as :TLSv1, :TLSv1_1and :TLSv1_2respectively).
对于进一步的细节,也看看OpenSSL的自己的文档关于这个问题,你可以将什么东西被说一下TLSv1_method到TLSv1_1_method和TLSv1_2_method(Ruby中的代表:TLSv1,:TLSv1_1并:TLSv1_2分别)。
If your underlying OpenSSL supports TLS 1.2 (>= 1.0.1 does), you're good to go. However, this requires a Ruby build from trunk currently. But if we get no negative feedback in the meantime, it might well be that it will be backported to the next 1.9.3 release.
如果您的底层 OpenSSL 支持 TLS 1.2(>= 1.0.1 支持),那么您就可以开始了。但是,目前这需要从主干构建 Ruby。但是如果我们在此期间没有收到负面反馈,它很可能会被移植到下一个 1.9.3 版本。

