-
Notifications
You must be signed in to change notification settings - Fork 238
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
692242f
commit 02159ab
Showing
1 changed file
with
44 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,45 @@ | ||
# local-cert-generator | ||
# 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. Trust this certificate after importing it to your System keychain: | ||
|
||
 | ||
|
||
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) | ||
``` |