Skip to content

Instantly share code, notes, and snippets.

@alexhayes
Forked from tadast/ssl_puma.sh
Last active November 1, 2018 03:19
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 alexhayes/b19562d84f9d844682ce8ebbe18f395b to your computer and use it in GitHub Desktop.
Save alexhayes/b19562d84f9d844682ce8ebbe18f395b to your computer and use it in GitHub Desktop.
localhost SSL with puma
# 1) Create your private key (any password will do, we remove it below)
$ cd ~/.ssh
$ mkdir local
$ 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 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)
Country Name (2 letter code) [AU]:
...
Common Name: localhost
...
# 4) Generate self signed ssl certificate
$ openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
# 5) Boot puma
$ puma -b 'ssl://localhost:3000?key=/Users/username/.ssh/local/server.key&cert=/Users/username/.ssh/local/server.crt'
# 6) Add server.crt as trusted !!SYSTEM!! (not login) cert in the mac osx keychain
# Open keychain tool, drag .crt file to system, and trust everything.
# Notes:
# 1) Https traffic and http traffic can't be served from the same 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