How to add SSL to your local development environment using Ruby on Rails with Puma
Sources:
- https://dev.to/matayoshimariano/how-to-add-ssl-to-your-localhost-development-environment-using-ruby-on-rails-with-puma-14di
- https://github.com/FiloSottile/mkcert
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'