Skip to content

Instantly share code, notes, and snippets.

@Jurawa
Last active December 9, 2021 22:24
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Jurawa/04ee9244a992a4590fcc6b52bbca0ef5 to your computer and use it in GitHub Desktop.
Save Jurawa/04ee9244a992a4590fcc6b52bbca0ef5 to your computer and use it in GitHub Desktop.
Rails local development with SSL on Mac OS X

Assumes you will be running your local app at local.dev, and already have a hosts file entry for this domain pointing to 127.0.0.1.

Generate self-signed cert and key

openssl req -new -newkey rsa:2048 -sha1 -days 365 -nodes -x509 -keyout ~/path/to/local.dev.key -out ~/path/to/local.dev.crt

You can leave all the address and organization info blank.

For the common name use local.dev, or *.local.dev if you want to access subdomains.

Trust the cert in keychain

Add the cert to keychain

open /Applications/Utilities/Keychain\ Access.app ~/path/to/local.dev.crt

Follow these instructions to trust the cert: https://gist.github.com/jed/6147872#avoid-https-warnings-by-telling-os-x-to-trust-the-certificate

Start rails using thin with ssl options

thin start --ssl --ssl-key-file ~/path/to/local.dev.key --ssl-cert-file ~/path/to/local.dev.crt

Sources

https://gist.github.com/jed/6147872

https://gist.github.com/trcarden/3295935#gistcomment-772362

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment