• Stars
    star
    1,363
  • Rank 34,478 (Top 0.7 %)
  • Language
    Shell
  • Created about 6 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A bash script for generating trusted self-signed SSL certs for local development on your Mac

Generate Self-Signed SSL Certificates for Local Development On A Mac

Have you ever need to develop HTTPS sites locally? To make it work you need to generate a SSL certificate of your own and tell your computer to trust it so you don't get weird Your connection is not private errors in your browser.

Generating the certs is a complicated hassle. So I made a bash script to do it all for you.

(Props to https://deliciousbrains.com/ssl-certificate-authority-for-local-https-development/ for most of the background info to get this script working)

How do I use this?

  • Clone or download a zip of this repo
  • Navigate to the directory containing generate-ssl.sh
  • Edit the options.conf file to add all of the domain names you want included in the certificate
  • Edit the certificate-authority-options.conf file if you want to tweak the settings used to generate the certificate authority certificate (optional)
  • Run sudo ./generate-ssl.sh local.dev where local.dev is the name of the cert that will be generated
  • The script will ask you for your system password which it needs to add the root certificate to Keychain
  • The next prompts for passwords will be just for the generation of the certs. It doesn't matter what your password is so long as you enter the same one every time it asks
  • That's it! Your certificate and private key will be in the your-certs/ directory. Do with them what you like.

Here is the sample output after running the script:

sudo ./generate-ssl.sh local.dev
Password:
Generating RSA private key, 2048 bit long modulus
..........+++
..............................................+++
e is 65537 (0x10001)
Enter pass phrase for tmp/local.devCA.key:
Verifying - Enter pass phrase for tmp/local.devCA.key:
Enter pass phrase for tmp/local.devCA.key:
Generating RSA private key, 2048 bit long modulus
...............+++
.........+++
e is 65537 (0x10001)
Signature ok
subject=/C=US/ST=Fake State/L=Fake Locality/O=Fake Company/CN=local.dev
Getting CA Private Key
Enter pass phrase for tmp/local.devCA.key:
All done! Check the your-certs directory for your certs.

What does this script do?

When you run this script it will

  • Create a fake certificate authority used to sign your own SSL certificate so your browser will trust it
  • Run all of the openssl commands to generate a root certificate (.pem) so your system will trust your self-signed certificate, a public certificate (.crt) that your server sends to clients, and a private key for the certificate (.key) to encrypt and decrypt data sent between the server and client
  • Add the generated root certificate to MacOS' Keychain so the operating system can trust the certificates you sign yourself
  • Reads all options from two configuration files so you can customize things to meet your needs

"It Didn't Work"

  • -bash: ./generate-ssl.sh: Permission denied If the script isn't executeable you can make it executeable by typing: chmod +x generate-ssl.sh

  • OpenSSL isn't installed. You need that to generate SSL certificates. You can install openssl using Brew: brew install openssl. If you don't have Brew see https://brew.sh/

  • Open keychain and search for a certificate with the name you passed as an argument to the script. If you ran the script as sudo ./generate-ssl.sh local.dev then look for a certificate named local.dev

  • Firefox doesn't use the macOS keychain (it maintains its own certificate store), In order for your CA-signed certificates to be recognized by Firefox you'll need to go into the Firefox settings and manually add the pem file to Firefox.

Other Scripts

More Repositories

1

dummyimage

Source code behind https://dummyimage.com
PHP
428
star
2

stickyHeader

Makes table headers stick to the top of the viewport when scrolling down HTML data tables.
HTML
94
star
3

sprig

Bare bones Twig templating support for WordPress
PHP
40
star
4

zadieheimlich

Files for ZadieHeimlich.com
PHP
19
star
5

WP-Gizmos

Per-post/page/whatever Widgets
PHP
13
star
6

wordpress-slack-notifications

Send Slack notifications based on WordPress actions like when a post is published or deleted
PHP
11
star
7

wordpress-cdn-integration

PHP
8
star
8

wordpress-screw-it-just-use-google

WordPress + Google.com + "site:" = THE BEST SEARCH EVER!
PHP
4
star
9

scaling-wordpress-on-aws

Slides for my talk about scaling WordPress on Amazon Web Services at WordCamp Baltimore 2016
JavaScript
4
star
10

jquery-events-presentation

Slides from my talk about jQuery Events as part of DC jQuery Meetup #18 Back to Basics
JavaScript
3
star
11

wordpress-twitter-backerupper

A WordPress plugin to backup your tweets
PHP
3
star
12

WP-Cache-Rules-Everything-Around-Me

My presentation about WordPress and caching from WordCamp Baltimore 2013
CSS
2
star
13

wordpress-child-themes

A set of WordPress themes for my children.
PHP
2
star
14

migrating-wordpress

My presentation for WordPress DC on migrating WordPress
JavaScript
2
star
15

wordpress-better-plugins-plugin

This WordPress plugin makes dealing with plugins easier by providing tools for filtering, comparing, and reporting plugins.
PHP
2
star
16

wp-styleguide

Simple plugin for enabling a styleguide for your WordPress theme
PHP
1
star
17

The-Great-Testing-Repository

I suck at GIT so this is how I'll learn.
HTML
1
star
18

searching-for-a-better-wordpress-search

Slides for my talk about WordPress search at WordCamp Lancaster 2016
HTML
1
star
19

wordpress-tweet-tweeeeeeeeeet

A WordPress theme to display your archived tweets. Requires the Twitter Backerupper plugin.
CSS
1
star
20

ConvergeSE-Map

A Google Mashup of Twitter data of the ConvergeSE attendees.
1
star
21

wordpress-cache-busting-path

Modifies a file name adding the last modified timestamp for cache busting purposes.
PHP
1
star
22

Scraping-Sochi-2014-Athlete-Profiles

PHP
1
star
23

wordpress

1
star
24

testing-github-actions

Simple deployment of a repo via SSH
JavaScript
1
star
25

wordpress-featured-post-ids-admin-ui

Admin UI for selecting and sorting featured post IDs on term archive pages
PHP
1
star