Coder Social home page Coder Social logo

create-ssl-certificate's Introduction

create-ssl-certificate

Command line tool to create self signed SSL certificate

Based on the following amazing GIST.

NOTE!

  1. This only works on MAC!

  2. Requires Node version 8 or higher

Create

In the folder of your project use the NPM executer:

npx create-ssl-certificate

This will create a certificate for the domain: FOLDER_NAME.test and any subdomain.

Options

Hostname

npx create-ssl-certificate --hostname myproject

This will create a certificate for the domain: myproject.test and any subdomain.

Domain

npx create-ssl-certificate --hostname myproject --domain localhost

This will create a certificate for the domain: myproject.test and any subdomain. Only test and localhost are recommended because they are specifically reserved as special-use domains.

Route to localhost

You choose either 1. or 2.

1. Simple setup

This setup only works for the specific hostname and no subdomains. Add the following, where you replace hostname and top level domin name to your own configuration:

127.0.0.1    myproject.test

to your /etc/hosts file.

2. Universal setup

You can do a "one time" setup, which works on all hostnames for the given top level domain, etc. .test. A good solution is dnsmasq. Install it via homebrew.

brew install dnsmasq

To make it start when your mac boots up:

brew services start dnsmasq

To route all top level domain lookups to localhost you will have to run these commands. Replace test in both echo commands if you chose a different top level domain.

mkdir -pv $(brew --prefix)/etc
sudo cp -v $(brew --prefix dnsmasq)/homebrew.mxcl.dnsmasq.plist /Library/LaunchDaemons
sudo launchctl load -w /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist
sudo mkdir -pv /etc/resolver
echo "address=/.test/127.0.0.1" | sudo tee -a $(brew --prefix)/etc/dnsmasq.conf
echo "nameserver 127.0.0.1" | sudo tee /etc/resolver/test

You usually have to restart your computer for this to take proper effect.

create-ssl-certificate's People

Contributors

christianalfoni avatar jartek avatar mgolshan avatar mikaelbr avatar rynop avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

create-ssl-certificate's Issues

us.org not valid domain name?

i bought a https://us.org/ domain recently, and need to setup a local equivalent for testing certain things (captcha, etc). in other words, i want to generate a cert for something like local.hostname.us.org

i can make certs for other domains (org, com, etc) but when I try to use us.org it fails

Problem with having number in hostname

Maybe this could work better:

  if (typeof text !== 'string' || !text.match(/^[a-zA-Z\-0-9]+$/)) {
    console.error(colors.red + `You did not pass in a valid hostname`)
    process.exit(1)
  }

Add option to auto add to hosts file?

Opening for discussion: How about as a part of the process, you get asked (if dnsmasq service isn't running and it doesn't already exists) to add domain to hosts file?

Example flow:

▶ npx create-ssl-certificate --hostname myproject --domain test
npx: installed 1 in 3.764s

✔ Certificate for *.myproject.test created successfully!

Press any key to open Keychain Access, then:

  1. Double click added certificate and expand the "Trust" section
  2. Change to "Always trust" on first dropdown
  3. If your certificate is not there you can drag and drop "ssl.crt" from this folder into Keychain Access

Note! Make sure `myproject.test` is routed to localhost. More info: https://github.com/christianalfoni/create-ssl-certificate
? Whould you like to add it to hosts file? (yN) y

✔ Routed myproject.test to 127.0.0.1

Path to Keychain Access.app

I'm seeing this error, on 10.15.5 Catalina

Something wrong happened, Command failed: open /Applications/Utilities/Keychain\ Access.app ssl.crt
The file /Applications/Utilities/Keychain Access.app does not exist.

My KeyChain Access.app is under /System/Applications/Utilities/Keychain\ Access.app. Everything works if I edit the path

Add option to set the certificate file name

Hello Christian and thank you very much for this great tool.

I use it with this https://github.com/jwilder/nginx-proxy which requires all the certificates to be in a specific folder with names like <hostname>.<domain>.crt and <hostname>.<domain>.key.

This works great but I have to rename the files manually before to open keychain access.

Is it possible to pass an option to create-ssl-certificate to set the file names like so?

(I wrote about it here: https://medium.com/@francoisromain/set-a-local-web-development-environment-with-custom-urls-and-https-3fbe91d2eaf0)

Thank you

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.