Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails, Windows and HTTPS

My objective is to pass from a standard HTTP server to a more safe HTTPS one.

My setup is: Ruby 2.0.0p598, Rails 4.2.0, Thin 1.6.3, Windows 7-Pro-x64-SP1

What I did: Using a self-signed certificate I try to start the server with:

thin start --ssl --ssl-key-file ssl/server.key --ssl-cert-file ssl/server.crt

What is the issue: I receive the following error:

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.

My question to you: Do you know if it is a general issue on Windows (therefore I cannot even think to succeed in doing it) or is there a way to let thin work with ssl on Windows?

like image 319
Mauro P. Avatar asked Feb 10 '15 11:02

Mauro P.


1 Answers

This is a duplicate of: Install OpenSSL with Ruby for eventmachine on Windows 7 x86

I will put same answer as there:

using rubyinstaller-2.1.6.exe, DevKit-mingw64-32-4.7.2-20130224-1151-sfx.exe and OpenSSL (http://slproweb.com/download/Win32OpenSSL-1_0_2c.exe or newer) in C:\OpenSSL

gem install eventmachine -- --with-ssl-dir=C:\OpenSSL

succeeds but then running thin with ssl fails in usual manner:

Encryption not available on this event-machine

You see above how to pass parameter to the native gem setup which should help you. We still need to find a set of parameters which will allow to built the thing correctly.

how to make

checking for main() in -lssl... no

a yes...?

after half a day of digging I have patched eventmachine to correctly search for ssl libs on windows so use below line in gemfile until changes are merged:

gem 'eventmachine', :github => 'krzcho/eventmachine', :branch => 'master'

before installing the bundle specify location of ssl (it must be full version of ssl with developer headers/libs)

bundle config build.eventmachine --with-ssl-dir=c:/OpenSSL

i also needed to make my own thin which is not activating another eventmachine so another line in gemfile is needed:

gem 'thin', :github => 'krzcho/thin', :branch => 'master'

unfortunately i still have problem when using non-self signed cert: thin rails server/eventmachine on windows does not work with custom certificate (case closed - wrong cert)

like image 135
Kodak Avatar answered Sep 29 '22 18:09

Kodak