Update README.md

This commit is contained in:
AJ ONeal 2015-12-13 01:04:44 -08:00
parent ef9dfe4107
commit ee4570322c
1 changed files with 68 additions and 33 deletions

101
README.md
View File

@ -11,6 +11,12 @@ Automatic [Let's Encrypt](https://lettsencrypt.org) HTTPS Certificates for node.
* Free SSL (HTTPS Certificates for TLS) * Free SSL (HTTPS Certificates for TLS)
* [90-day certificates](https://letsencrypt.org/2015/11/09/why-90-days.html) * [90-day certificates](https://letsencrypt.org/2015/11/09/why-90-days.html)
**See Also**
* See the node-letsencrypt [Examples](https://github.com/Daplie/node-letsencrypt/tree/master/examples)
* [Let's Encrypt in (exactly) 90 seconds with Caddy](https://daplie.com/articles/lets-encrypt-in-literally-90-seconds/)
* [lego](https://github.com/xenolf/lego): Let's Encrypt for golang
Install Install
======= =======
@ -19,7 +25,7 @@ npm install --save letsencrypt
``` ```
Right now this uses [`letsencrypt-python`](https://github.com/Daplie/node-letsencrypt-python), Right now this uses [`letsencrypt-python`](https://github.com/Daplie/node-letsencrypt-python),
but it's built to be able to use a pure javasript version (in progress). but it's built to be able to use a node-only javasript version (in progress).
```bash ```bash
# install the python client (takes 2 minutes normally, 20 on a rasberry pi) # install the python client (takes 2 minutes normally, 20 on a rasberry pi)
@ -35,36 +41,54 @@ There are a few partially written javascript implementation, but they use `forge
Once the `forge` crud is gutted away it should slide right in without a problem. Ping [@coolaj86](https://coolaj86.com) if you'd like to help. Once the `forge` crud is gutted away it should slide right in without a problem. Ping [@coolaj86](https://coolaj86.com) if you'd like to help.
Usage Examples Usage
======== =====
Here's a small snippet: Here's a simple snippet:
```javascript ```
var config = require('./examples/config-minimal');
config.le.webrootPath = __dirname + './tests/acme-challenge';
var le = require('letsencrypt').create(config.backend, config.le);
le.register({ le.register({
domains: ['example.com', 'www.example.com'] agreeTos: true
, email: 'user@example.com' , domains: ['example.com'] // CHANGE TO YOUR DOMAIN
, agreeTos: true , email: 'user@email.com' // CHANGE TO YOUR EMAIL
, webrootPath: '/srv/www/example.com/public' }, function (err) {
}, function (err, certs) { if (err) {
// do stuff console.error('[Error]: node-letsencrypt/examples/standalone');
console.error(err.stack);
} else {
console.log('success');
}
plainServer.close();
tlsServer.close();
}); });
// IMPORTANT
// you also need BOTH an http AND https server
//
// app.use('/', express.static(config.le.webrootPath))
``` ```
**However**, due to the nature of what this library does, it has a few more "moving parts" **However**, due to the nature of what this library does, it has a few more "moving parts"
than what makes sense to show in a minimal snippet. than what makes sense to show in a minimal snippet.
### One Time Registration Examples
========
* [commandline (standalone with "webroot")](https://github.com/Daplie/node-letsencrypt/blob/master/examples/commandline.js) ### One-Time Registration
```bash Register a 90-day certificate manually, on a whim
# manual standalone registration via commandline
# (runs against testing server on tls port 5001) #### Snippets
node examples/commandline.js example.com,www.example.com user@example.net agree
```
[`commandline-minimal`](https://github.com/Daplie/node-letsencrypt/blob/master/examples/commandline-minimal.js): [`commandline-minimal`](https://github.com/Daplie/node-letsencrypt/blob/master/examples/commandline-minimal.js):
**Part 1: the Let's Encrypt client**:
```javascript ```javascript
'use strict'; 'use strict';
@ -95,8 +119,10 @@ le.register({
plainServer.close(); plainServer.close();
tlsServer.close(); tlsServer.close();
}); });
```
**Part 2: Express Web Server**:
```javascript
// //
// Express App // Express App
// //
@ -121,10 +147,22 @@ var tlsServer = require('https').createServer({
}); });
``` ```
#### Runnable Demo
* [commandline (standalone with "webroot")](https://github.com/Daplie/node-letsencrypt/blob/master/examples/commandline.js)
```bash
# manual standalone registration via commandline
# (runs against testing server on tls port 5001)
node examples/commandline.js example.com,www.example.com user@example.net agree
```
### Express ### Express
Fully Automatic HTTPS with ExpressJS using Free SSL certificates from Let's Encrypt Fully Automatic HTTPS with ExpressJS using Free SSL certificates from Let's Encrypt
#### Snippets
* [Minimal ExpressJS Example](https://github.com/Daplie/node-letsencrypt/blob/master/examples/express-minimal.js) * [Minimal ExpressJS Example](https://github.com/Daplie/node-letsencrypt/blob/master/examples/express-minimal.js)
```javascript ```javascript
@ -190,6 +228,8 @@ require('https').createServer({
}); });
``` ```
#### Runnable Example
* [Full ExpressJS Example](https://github.com/Daplie/node-letsencrypt/blob/master/examples/express.js) * [Full ExpressJS Example](https://github.com/Daplie/node-letsencrypt/blob/master/examples/express.js)
```bash ```bash
@ -225,23 +265,18 @@ and then make sure to set all of of the following to a directory that your user
* `logsDir` (python backend only) * `logsDir` (python backend only)
See Also
========
* See [Examples](https://github.com/Daplie/node-letsencrypt/tree/master/examples)
* [Let's Encrypt in (exactly) 90 seconds with Caddy](https://daplie.com/articles/lets-encrypt-in-literally-90-seconds/)
* [lego](https://github.com/xenolf/lego): Let's Encrypt for golang
API API
=== ===
* `LetsEncrypt.create(backend, bkDefaults, handlers)` ```javascript
* `le.middleware()` LetsEncrypt.create(backend, bkDefaults, handlers)
* `le.sniCallback(hostname, function (err, tlsContext) {})` le.middleware()
* `le.register({ domains, email, agreeTos, ... }, cb)` le.sniCallback(hostname, function (err, tlsContext) {})
* `le.fetch({domains, email, agreeTos, ... }, cb)` le.register({ domains, email, agreeTos, ... }, cb)
* `le.validate(domains, cb)` le.fetch({domains, email, agreeTos, ... }, cb)
* `le.registrationFailureCallback(err, args, certInfo, cb)` le.validate(domains, cb)
le.registrationFailureCallback(err, args, certInfo, cb)
```
### `LetsEncrypt.create(backend, bkDefaults, handlers)` ### `LetsEncrypt.create(backend, bkDefaults, handlers)`