with love

This commit is contained in:
AJ ONeal 2014-07-15 03:38:33 +00:00
parent 1b5ba16ad6
commit 5c8cf158db
5 changed files with 59 additions and 16 deletions

4
.gitignore vendored
View File

@ -1,3 +1,7 @@
all/
server/
client/
# Logs
logs
*.log

View File

@ -1,15 +1,33 @@
nodejs-self-signed-certificate-example
======================================
An example that works.
The end off all your self-signed certificate woes (in node.js at least)
This is an easy-as-git-clone example that will get you on your way without
any `DEPTH_ZERO_SELF_SIGNED_CERT` or `SSL certificate problem: Invalid certificate chain` headaches.
See
[the explanation](https://github.com/coolaj86/node-ssl-root-cas/wiki/Painless-Self-Signed-Certificates-in-node.js) for
the many details.
Test for yourself
---
This is an easy-as-git-clone example that will get you on your way without
any `DEPTH_ZERO_SELF_SIGNED_CERT` or `SSL certificate problem: Invalid certificate chain` headaches.
An example that works.
```bash
example
├── package.json
├── make-root-ca-and-certificates.sh
├── serve.js
├── request-without-warnings.js
├── server
|   ├── my-private-root-ca.crt.pem
|   ├── my-server.crt.pem
|   └── my-server.key.pem
└── client
   └── my-private-root-ca.crt.pem
```
### Get the repo
@ -25,7 +43,7 @@ npm install
bash test.sh
```
### Create certificates for `local.ldsconnect.org`
### Create certificates for your FQDN
`local.ldsconnect.org` points to `localhost`, so it's ideal for your first test.
@ -36,7 +54,7 @@ bash make-root-ca-and-certificates.sh 'local.ldsconnect.org'
### Run the server
```bash
node ./serve.js 4443 &
node ./serve.js 8043 &
# use `fg` and `ctrl+c` to kill
```
@ -50,7 +68,7 @@ Visit in a web browser
Test (warning free) in node.js
```bash
node ./request-without-warnings.js 4443
node ./request-without-warnings.js 8043
```
Test (warning free) with cURL

View File

@ -5,11 +5,12 @@ var https = require('https')
, fs = require('fs')
, path = require('path')
, ca = fs.readFileSync(path.join(__dirname, 'client', 'my-private-root-ca.crt.pem'))
, port = process.argv[2] || 4443
, port = process.argv[2] || 8043
, hostname = process.argv[3] || 'local.ldsconnect.org'
;
var options = {
host: 'local.ldsconnect.org'
host: hostname
, port: port
, path: '/'
, ca: ca

View File

@ -2,7 +2,7 @@
'use strict';
var https = require('https')
, port = process.argv[2] || 4443
, port = process.argv[2] || 8043
, fs = require('fs')
, path = require('path')
, server

32
test.sh
View File

@ -1,10 +1,30 @@
#!/bin/bash
bash make-root-ca-and-certificates.sh 'local.ldsconnect.org'
node ./serve.js &
sleep 2
node ./request-without-warnings.js
echo ""
echo ""
node ./serve.js 8043 &
NODE_PID=$!
sleep 1
echo ""
echo ""
node ./request-without-warnings.js 8043 'local.ldsconnect.org'
echo -n " - without warnings, love node.js' https"
echo ""
sleep 1
echo ""
curl https://local.ldsconnect.org:8043 \
--cacert client/my-private-root-ca.crt.pem
echo -n " - without warnings, love cURL"
echo ""
sleep 1
# For lots of output about the ssl connection try -v
#curl -v https://local.ldsconnect.org:8043 \
# --cacert client/my-private-root-ca.crt.pem
kill ${NODE_PID}
echo ""