我在/opt/openssl中有一个新的OpenSSL安装(从源代码编译了1.1.0),在/opt/ruby中也有一个新的编译(来自源代码的2.1.0dev),它使用-=/opt/openssl(都在当前的Debian上)编译。Openssl可以看到我计算机的rdrand引擎
$ openssl engine
(rdrand) Intel RDRAND engine
(dynamic) Dynamic engine loading supportRuby可以看到openssl
$ ruby -ropenssl -e 'p OpenSSL::Random.random_bytes(4)'
"Q\a\"%"OpenSSL::Engine在那里,也可以加载一个引擎:
$ ruby -ropenssl -e 'e=OpenSSL::Engine.by_id("openssl"); p e;'
#<OpenSSL::Engine id="openssl" name="Software engine support">如果我现在尝试使用这个设置来调用rdrand生成器,我会得到以下内容:
$ ruby -ropenssl -e 'OpenSSL::Engine.by_id("rdrand"); p OpenSSL::Random.random_bytes(4)'
-e:1:in `by_id': no such engine (OpenSSL::Engine::EngineError)
from -e:1:in `<main>'我在这里做傻事吗?一般情况下:我如何在Ruby中使用OpenSSL并需要一个特定的openssl引擎?
发布于 2013-10-07 14:48:27
找到了,你必须先装上所有引擎:
$ ruby -ropenssl -e 'OpenSSL::Engine.load; e = OpenSSL::Engine.by_id("rdrand"); p e;'
#<OpenSSL::Engine id="rdrand" name="Intel RDRAND engine">其实很简单。
https://stackoverflow.com/questions/18764001
复制相似问题