Skip to content

Instantly share code, notes, and snippets.

@mbijon
Forked from demisx/webrick-ssl.rb
Created April 22, 2021 16:14
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 mbijon/5ea08d832487bcc8395ea29c7b8082c8 to your computer and use it in GitHub Desktop.
Save mbijon/5ea08d832487bcc8395ea29c7b8082c8 to your computer and use it in GitHub Desktop.
Configure Webrick Server as SSL
#!/usr/bin/env ruby
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("lib/support/ssl/colddata.com.key").read),
SSLCertificate: OpenSSL::X509::Certificate.new(File.open("lib/support/ssl/colddata.com.crt").read),
SSLCertName: [["CN", WEBrick::Utils::getservername]]
})
end
end
end
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'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment