Skip to content

Instantly share code, notes, and snippets.

@karmatr0n
Created May 18, 2010 21:06
Show Gist options
  • Save karmatr0n/405549 to your computer and use it in GitHub Desktop.
Save karmatr0n/405549 to your computer and use it in GitHub Desktop.
#
# Example of config.ru for Application based on Sinatra + WeBrick + SSL
#
require File.dirname(__FILE__) + '/environment'
require File.dirname(__FILE__) + '/your_sinatra_app'
require 'webrick'
require 'webrick/https'
certificate = "/your/path/certs/myssl.crt"
private_key = "/your/path/certs/myssl.key"
ssl_options = {
:Port => 443,
:SSLEnable => true,
:SSLVerifyClient => OpenSSL::SSL::VERIFY_NONE,
:SSLCertificate => OpenSSL::X509::Certificate.new(File.open(certificate).read),
:SSLPrivateKey => OpenSSL::PKey::RSA.new(File.open(private_key).read),
:SSLCertName => [ [ "CN", WEBrick::Utils::getservername ] ]
}
server = WEBrick::HTTPServer.new(options)
server.mount "/", Rack::Handler::WEBrick, YourSinatraApp.new
Signal.trap(:INT) { server.shutdown }
server.start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment