Jonathan Bennett

Unlock Push Notifications with This Simple SSL Setup

Push notifications are a powerful tool, but getting them set up can feel overwhelming. Before diving into notifications themselves, there’s a crucial first step: enabling SSL. Push notifications require a secure connection, even in your local development environment.

The easiest way to enable SSL locally is with mkcert. This tool allows you to trust your own computer as a certificate authority, making it perfect for local testing (and only for local testing).

Here’s how to get started:

Step 1: Install mkcert

Follow the installation instructions for your platform. On macOS with Homebrew, you can install it with just a few commands:

brew install mkcert  
mkcert -install  
mkcert localhost  

These steps will:

  1. Install mkcert on your system.
  2. Set up your computer as a trusted certificate authority.
  3. Generate SSL certificates for localhost.

Step 2: Configure Your Rails Server

Update your Procfile.dev (or equivalent) to use the generated certificates. For example:

# Procfile.dev
# web: unset PORT && bin/rails server -b 0.0.0.0  
web: unset PORT && bin/rails s -b 'ssl://0.0.0.0:3000?key=localhost-key.pem&cert=localhost.pem'  

This tells Rails to serve your app over HTTPS using the localhost certificates created by mkcert.

And that’s it—your local environment is now HTTPS-enabled!

In the next email, we’ll cover automating this process and streamlining your setup further. Stay tuned!