Created
May 25, 2016 03:52
-
-
Save mostlyfine/e50107d86e83a2a9049c21eec988d563 to your computer and use it in GitHub Desktop.
Creating an SSL certificate for Sinatra
This file contains hidden or 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
require "webrick" | |
require "webrick/https" | |
require "openssl" | |
require 'sinatra' | |
configure do | |
cn = [[ "CN", WEBrick::Utils::getservername]] | |
cert, rsa = WEBrick::Utils::create_self_signed_cert(2048, cn, "Generated by Ruby/OpenSSL") | |
set :server_settings, { | |
SSLEnable: true, | |
SSLVerifyClient: OpenSSL::SSL::VERIFY_NONE, | |
SSLCertificate: OpenSSL::X509::Certificate.new(cert.to_s), | |
SSLPrivateKey: OpenSSL::PKey::RSA.new(rsa.to_s), | |
SSLCertName: cn, | |
} | |
end | |
get "/" do | |
"hello SSL world!" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
curl -k https://localhost:4567/