Skip to content

Instantly share code, notes, and snippets.

@ktec
Forked from tadast/ssl_puma.sh
Created January 17, 2017 13:43
Show Gist options
  • Select an option

  • Save ktec/c53f9bdf10fa15e69b91f5066db67190 to your computer and use it in GitHub Desktop.

Select an option

Save ktec/c53f9bdf10fa15e69b91f5066db67190 to your computer and use it in GitHub Desktop.
localhost SSL with puma
# SSL self signed localhost for rails start to finish, no red warnings.
# 1) Create your private key (any password will do, we remove it below)
$ openssl genrsa -des3 -out server.orig.key 2048
# 2) Remove the password
$ openssl rsa -in server.orig.key -out server.key
# 3) Generate the csr (Certificate signing request) (Details are important!)
$ openssl req -new -key server.key -out server.csr
# IMPORTANT
# MUST have localhost.ssl as the common name to keep browsers happy
# (has to do with non internal domain names ... which sadly can be
# avoided with a domain name with a "." in the middle of it somewhere)
...
Common Name: localhost.ssl
...
# 5) Finally Add localhost.ssl to your hosts file
$ echo "127.0.0.1 localhost.ssl" | sudo tee -a /private/etc/hosts
# 6) Boot thin
$ thin start --ssl --ssl-verify --ssl-key-file certs/server.key --ssl-cert-file certs/server.crt
7) Add server.crt as trusted cert in mac osx keychain
# Notes:
# 1) Https traffic and http traffic can't be served from the same thin process. If you want
# both you need to start two instances on different ports.
#
#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment