Search code examples
ruby-on-railsruby-on-rails-3sslhttpswebrick

Ruby on Rails WEBrick SSL connection error


Please help to implement ssl

rails version - 3.2.8

I edtited following files:

# Gemfile
gem 'rack-ssl'

 # config/application.rb
require 'rack/ssl'
config.middleware.use Rack::SSL

I also tried to use

# config/application.rb
config.force_ssl = true

But it shows

SSL connection error

when I access mysite:3000/

But it shows normal page if going to https:mysite

Please help,

thanks,

D


Solution

  • According to this:

    How to use deactivate Webrick's SSL

    The issue is caused by config.force_ssl = true. Even if you remove that, which you may not want, you might still have issues with WEBrick giving you this error. You could try clearing cookies, but that still might not work.

    A better alternative, if it's an option for you, would be to switch to using the thin server:

    group :development do
       gem "thin"
    end
    

    Then:

    $ bundle
    $ thin start --ssl
    

    See also https://stackoverflow.com/a/11614213