Having a Rails local development environment with SSL/HTTPS support can be very handy. You can work with payment plaforms APIs, like Stripe or Apple Pay, without having to resort to tools like ngrok and you can increase development/production parity.
You can configure Puma to use SSL only in development environment with a
config/puma.rb file like this:
To easily generate a self-signed and locally-trusted development SSL certificate for your Rails application, you can use mkcert.
Create and install a local Certification Authority:
Create corresponding certificate and key files in the
mkdir -p config/certs mkcert -cert-file config/certs/localhost.pem -key-file config/certs/localhost-key.pem localhost
You can use mkcert to install the same development CA you’ve created on any other development box.
Copy the CA certificate to your application:
cp "$(mkcert -CAROOT)/rootCA.pem" config/certs
Install the same CA on another machine (you can add this step to your
CAROOT=config/certs mkcert -install