-
-
Save BrentonEarl/4e4b2e36c69ace7fc42f6901f0345205 to your computer and use it in GitHub Desktop.
Sinatra + SSL
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
#!/usr/bin/env ruby | |
# | |
# This code snippet shows how to enable SSL in Sinatra. | |
# | |
require 'sinatra/base' | |
class Application < Sinatra::Base | |
configure do | |
set :bind, '0.0.0.0' | |
set :port, 443 | |
end | |
get '/' do | |
'Hello, SSL.' | |
end | |
def self.run! | |
super do |server| | |
server.ssl = true | |
server.ssl_options = { | |
:cert_chain_file => File.dirname(__FILE__) + "/server.crt", | |
:private_key_file => File.dirname(__FILE__) + "/server.key", | |
:verify_peer => false | |
} | |
end | |
end | |
run! if app_file == $0 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment