Rails,Windows和HTTPS

Mau*_* P. 6 windows https ruby-on-rails eventmachine

我的目标是从标准HTTP服务器传递到更安全的HTTPS服务器.

我的设置是: Ruby 2.0.0p598,Rails 4.2.0,Thin 1.6.3,Windows 7-Pro-x64-SP1

我做了什么:使用自签名证书我尝试使用以下命令启动服务器:

thin start --ssl --ssl-key-file ssl/server.key --ssl-cert-file ssl/server.crt
Run Code Online (Sandbox Code Playgroud)

问题:我收到以下错误:

terminate called after throwing an instance of 'std::runtime_error'
  what():  Encryption not available on this event-machine

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
Run Code Online (Sandbox Code Playgroud)

我向你提出的问题:你知道它是否是Windows上的一般问题(因此我甚至无法想到成功)或者是否有办法在Windows上轻松使用ssl?

Kod*_*dak 4

这是以下内容的副本:Install OpenSSL with Ruby for eventmachine on Windows 7 x86

我会给出与那里相同的答案:

在 C: 中使用 ruby​​installer-2.1.6.exe、DevKit-mingw64-32-4.7.2-20130224-1151-sfx.exe 和 OpenSSL(http://slproweb.com/download/Win32OpenSSL-1_0_2c.exe或更高版本) \OpenSSL

gem install eventmachine -- --with-ssl-dir=C:\OpenSSL
Run Code Online (Sandbox Code Playgroud)

成功,但使用 ssl 进行精简运行会以通常的方式失败:

Encryption not available on this event-machine
Run Code Online (Sandbox Code Playgroud)

您在上面看到了如何将参数传递给本机 gem 设置,这应该会对您有所帮助。我们仍然需要找到一组参数来正确构建该东西。

怎么做

checking for main() in -lssl... no
Run Code Online (Sandbox Code Playgroud)

是的...?

经过半天的挖掘,我已经修补了 eventmachine 以在 Windows 上正确搜索 ssl 库,因此在 gemfile 中使用以下行,直到合并更改:

gem 'eventmachine', :github => 'krzcho/eventmachine', :branch => 'master'
Run Code Online (Sandbox Code Playgroud)

在安装捆绑包之前指定 ssl 的位置(它必须是带有开发人员标头/库的完整版本的 ssl)

bundle config build.eventmachine --with-ssl-dir=c:/OpenSSL
Run Code Online (Sandbox Code Playgroud)

我还需要制作自己的thin,它不会激活另一个eventmachine,因此需要gemfile中的另一行:

gem 'thin', :github => 'krzcho/thin', :branch => 'master'
Run Code Online (Sandbox Code Playgroud)

不幸的是,我在使用非自签名证书时仍然遇到问题: Windows 上的 Thin Rails 服务器/eventmachine 无法使用自定义证书(案例已结-错误的证书)