Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dakshshah96/local-cert-generator
🚀 A set of scripts to quickly generate a HTTPS certificate for your local development environment.
https://github.com/dakshshah96/local-cert-generator
https https-certificate ssl-certificate
Last synced: 16 days ago
JSON representation
🚀 A set of scripts to quickly generate a HTTPS certificate for your local development environment.
- Host: GitHub
- URL: https://github.com/dakshshah96/local-cert-generator
- Owner: dakshshah96
- Created: 2018-01-19T06:14:34.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2021-06-29T18:56:22.000Z (over 3 years ago)
- Last Synced: 2024-04-27T20:37:35.163Z (7 months ago)
- Topics: https, https-certificate, ssl-certificate
- Language: Shell
- Homepage:
- Size: 7.81 KB
- Stars: 955
- Watchers: 25
- Forks: 234
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# HTTPS for `localhost`
A set of scripts to quickly generate a HTTPS certificate for your local development environment.
## How-to
1. Clone this repository and `cd` into it:
```
git clone https://github.com/dakshshah96/local-cert-generator.git
cd local-cert-generator
```
2. Run the script to create a root certificate:```
sh createRootCA.sh
```3. Add the root certificate we just generated to your list of trusted certificates. This step depends on the operating system you're running:
- **macOS**: Open Keychain Access and import the root certificate to your System keychain. Then mark the certificate as trusted.
![Trust root certificate](https://cdn-images-1.medium.com/max/1600/1*NWwMb0yV9ClHDj87Kug9Ng.png)
- **Linux**: Depending on your Linux distribution, you can use `trust`, `update-ca-certificates` or another command to mark the generated root certificate as trusted.
*Note*: You may need to restart your browser to load the newly trusted root certificate correctly.
4. Run the script to create a domain certificate for `localhost`:
```
sh createSelfSigned.sh
```5. Move `server.key` and `server.crt` to an accessible location on your server and include them when starting it. In an Express app running on Node.js, you'd do something like this:
```js
var path = require('path')
var fs = require('fs')
var express = require('express')
var https = require('https')var certOptions = {
key: fs.readFileSync(path.resolve('build/cert/server.key')),
cert: fs.readFileSync(path.resolve('build/cert/server.crt'))
}var app = express()
var server = https.createServer(certOptions, app).listen(443)
```