Skip to content

Instantly share code, notes, and snippets.

@roloenusa
Created March 8, 2011 02:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save roloenusa/859755 to your computer and use it in GitHub Desktop.
Save roloenusa/859755 to your computer and use it in GitHub Desktop.
Setting up Rails as a SSL server
=BEGIN
This is courtesy of:
http://www.nearinfinity.com/blogs/chris_rohr/configuring_webrick_to_use_ssl.html
=END
# All you have to do to get WEBrick running in SSL is modify the script/rails file and add the following lines (above the APP_PATH variable declaration):
require 'rubygems'
require 'rails/commands/server'
require 'rack'
require 'webrick'
require 'webrick/https'
module Rails
class Server < ::Rack::Server
def default_options
super.merge({
:Port => 3000,
:environment => (ENV['RAILS_ENV'] || "development").dup,
:daemonize => false,
:debugger => false,
:pid => File.expand_path("tmp/pids/server.pid"),
:config => File.expand_path("config.ru"),
:SSLEnable => true,
:SSLVerifyClient => OpenSSL::SSL::VERIFY_NONE,
:SSLPrivateKey => OpenSSL::PKey::RSA.new(
File.open("path/to/key").read),
:SSLCertificate => OpenSSL::X509::Certificate.new(
File.open("/path/to/crt").read),
:SSLCertName => [["CN", WEBrick::Utils::getservername]]
})
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment