Skip to content

Instantly share code, notes, and snippets.

@floptwo

floptwo/howto.md

Last active Nov 27, 2020
Embed
What would you like to do?
How to add SSL to your local development environment using Ruby on Rails with Puma

How to add SSL to your local development environment using Ruby on Rails with Puma

Sources:

brew install mkcert
brew install nss
mkcert -install
mkcert mywebsite.test "*.mywebsite.test"

Add the code below to your config/puma.rb

if ENV["RAILS_ENV"] == "development"
  clear_binds! # Remove the tcp:// binds that stops ssl:// to work
  ssl_bind "0.0.0.0", 3000, {
    key: File.join("config", "local-certs", "mywebsite-key.pem"),
    cert: File.join("config", "local-certs", "mywebsite.pem"),
    verify_mode: "none"
  }
end

So, to start your server you can do

rails s

instead of

rails s puma -b 'ssl://0.0.0.0:3001?cert=config/local-certs/mywebsite.pem&key=config/local-certs/mywebsite-key.pem&verify_mode=none&no_tlsv1=false&no_tlsv1_1=false'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment