Created
March 8, 2011 02:39
-
-
Save roloenusa/859755 to your computer and use it in GitHub Desktop.
Setting up Rails as a SSL server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=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