如何在 Ruby 中设置 SSLContext 选项 [英] How to set SSLContext options in Ruby
本文介绍了如何在 Ruby 中设置 SSLContext 选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要在 Ruby 1.8+ 中创建一个 SSLSocket
来与加密服务通信.我想在 SSLContext
对象上设置 SSL 选项(它最终在底层 OpenSSL 库中调用 SSL_CTX_set_options
).我没有看到任何明显的方法来做到这一点.
I need to create an SSLSocket
in Ruby 1.8+ to talk to an encrypted service. I want to set SSL options on the SSLContext
object (it eventually calls SSL_CTX_set_options
in the underlying OpenSSL library). I am not seeing any obvious way to do this.
这是使用 OpenSSL::SSL::SSLContext
接口.
作为参考,这类似于调用 set_options()
在 Python 的 pyOpenSSL 库中.
As a point of reference, this is analogous to calling the set_options()
in Python's pyOpenSSL library.
推荐答案
示例:
ctx = OpenSSL::SSL::SSLContext.new
ctx.set_params(:options => OpenSSL::SSL::OP_EPHEMERAL_RSA | OpenSSL::SSL::OP_NO_SSLv2)
# or
ctx.options = OpenSSL::SSL::OP_EPHEMERAL_RSA | OpenSSL::SSL::OP_NO_SSLv2
这篇关于如何在 Ruby 中设置 SSLContext 选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文