[ rails ] self sign SSL

Self Signed SSL

$ openssl req -x509 -sha256 -nodes -newkey rsa:2048 -days 365 -keyout localh ost.key -out localhost.crt

modify bin/rails

#!/usr/bin/env ruby
######### added ###################
require 'rails/commands/server'
require 'rack'
require 'webrick'
require 'webrick/https'

if ENV['SSL'] == "true"
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("/home/pong/Desktop/ssl/localhost.key").read),
:SSLCertificate => OpenSSL::X509::Certificate.new(
File.open("/home/pong/Desktop/ssl/localhost.crt").read),
:SSLCertName => [["CN", WEBrick::Utils::getservername]],
})
end
end
end
end
##########end added#####################

begin
load File.expand_path("../spring", __FILE__)
rescue LoadError
end
APP_PATH = File.expand_path('../../config/application', __FILE__)
require_relative '../config/boot'
require 'rails/commands'

Run a Server

$ SSL=true rails s

ref : https://www.devmynd.com/blog/rails-local-development-https-using-self-signed-ssl-certificate/,

https://stackoverflow.com/questions/3640993/how-do-you-configure-webrick-to-use-ssl-in-rails

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s