2016-04-22 12:11:58 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								[](https://gitter.im/Daplie/letsencrypt-express?utm_source=badge& utm_medium=badge& utm_campaign=pr-badge& utm_content=badge)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-08-16 14:31:34 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								| **letsencrypt** 
							 
						 
					
						
							
								
									
										
										
										
											2016-08-04 14:26:49 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								| [letsencrypt-cli ](https://github.com/Daplie/letsencrypt-cli )
							 
						 
					
						
							
								
									
										
										
										
											2016-04-22 12:18:30 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								| [letsencrypt-express ](https://github.com/Daplie/letsencrypt-express )
							 
						 
					
						
							
								
									
										
										
										
											2016-08-16 14:31:34 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								| [letsencrypt-cluster ](https://github.com/Daplie/letsencrypt-cluster )
							 
						 
					
						
							
								
									
										
										
										
											2016-04-22 12:17:54 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								| [letsencrypt-koa ](https://github.com/Daplie/letsencrypt-koa )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								| [letsencrypt-hapi ](https://github.com/Daplie/letsencrypt-hapi )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								|
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-08-08 09:13:34 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								letsencrypt
							 
						 
					
						
							
								
									
										
										
										
											2015-12-11 03:23:47 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								===========
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-08-05 03:03:27 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Automatic [Let's Encrypt ](https://letsencrypt.org ) HTTPS / TLS / SSL Certificates for node.js
							 
						 
					
						
							
								
									
										
										
										
											2015-12-11 03:23:47 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-08-08 09:13:34 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Free SLL with [90-day ](https://letsencrypt.org/2015/11/09/why-90-days.html ) HTTPS / TLS Certificates
							 
						 
					
						
							
								
									
										
										
										
											2015-12-13 01:04:44 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-08-09 17:17:22 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Are these the droids you're looking for?
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								------
							 
						 
					
						
							
								
									
										
										
										
											2016-04-18 17:01:35 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-08-05 03:03:27 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								This is a **low-level library**  for implementing ACME / LetsEncrypt Clients, CLIs,
							 
						 
					
						
							
								
									
										
										
										
											2016-04-18 17:01:35 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								system tools, and abstracting storage backends (file vs db, etc).
							 
						 
					
						
							
								
									
										
										
										
											2016-08-05 03:03:27 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-08-05 03:20:19 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								For `express` , raw `https`  or `spdy` , or `restify`  (same as raw https) see
							 
						 
					
						
							
								
									
										
										
										
											2016-08-16 14:32:35 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								[**letsencrypt-express** ](https://github.com/Daplie/letsencrypt-express ) and [letsencrypt-cluster ](https://github.com/Daplie/letsencrypt-cluster ).
							 
						 
					
						
							
								
									
										
										
										
											2016-04-18 17:01:35 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-08-05 03:20:19 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								For `hapi`  see [letsencrypt-hapi ](https://github.com/Daplie/letsencrypt-hapi ).
							 
						 
					
						
							
								
									
										
										
										
											2016-04-18 11:27:55 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-08-05 03:20:19 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								For `koa`  or `rill` 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								see [letsencrypt-koa ](https://github.com/Daplie/letsencrypt-koa ).
							 
						 
					
						
							
								
									
										
										
										
											2016-04-18 17:01:35 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-08-05 03:20:19 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								For `bash` , `fish` , `zsh` , `cmd.exe` , `PowerShell` 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								see [**letsencrypt-cli** ](https://github.com/Daplie/letsencrypt-cli ).
							 
						 
					
						
							
								
									
										
										
										
											2016-04-18 11:26:15 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-12-12 13:11:05 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Install
							 
						 
					
						
							
								
									
										
										
										
											2016-08-09 17:17:22 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								=======
							 
						 
					
						
							
								
									
										
										
										
											2015-12-12 13:11:05 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-08-05 03:20:19 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								`letsencrypt`  requires at least two plugins: 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								one for managing certificate storage and the other for handling ACME challenges.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								The default storage plugin is [`le-store-certbot` ](https://github.com/Daplie/le-store-certbot )
							 
						 
					
						
							
								
									
										
										
										
											2016-08-09 14:05:47 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								and the default challenge is [`le-challenge-fs` ](https://github.com/Daplie/le-challenge-fs ).
							 
						 
					
						
							
								
									
										
										
										
											2016-08-05 03:20:19 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-12-12 13:11:05 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```bash
							 
						 
					
						
							
								
									
										
										
										
											2016-08-05 03:03:27 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								npm install --save letsencrypt@2 .x
							 
						 
					
						
							
								
									
										
										
										
											2016-08-09 17:43:46 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								npm install --save le-store-certbot@2 .x   # default plugin for accounts, certificates, and keypairs
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								npm install --save le-challenge-fs@2 .x    # default plugin for challenge handlers
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								npm install --save le-acme-core@2 .x       # default plugin for ACME spec
							 
						 
					
						
							
								
									
										
										
										
											2016-08-11 10:43:07 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								npm install --save le-sni-auto@2 .x        # default plugin for SNICallback
							 
						 
					
						
							
								
									
										
										
										
											2015-12-12 13:11:05 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-12-13 01:04:44 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Usage
							 
						 
					
						
							
								
									
										
										
										
											2016-08-09 17:17:22 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								=====
							 
						 
					
						
							
								
									
										
										
										
											2015-12-12 22:16:02 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-08-05 03:03:27 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								It's very simple and easy to use, but also very complete and easy to extend and customize.
							 
						 
					
						
							
								
									
										
										
										
											2015-12-12 22:16:02 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-08-05 03:03:27 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								### Overly Simplified Example
  
						 
					
						
							
								
									
										
										
										
											2015-12-16 05:07:56 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-08-08 09:14:08 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Against my better judgement I'm providing a terribly oversimplified example
							 
						 
					
						
							
								
									
										
										
										
											2016-08-05 03:03:27 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								of how to use this library:
							 
						 
					
						
							
								
									
										
										
										
											2015-12-17 02:38:46 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-12-13 03:09:06 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```javascript
							 
						 
					
						
							
								
									
										
										
										
											2016-08-05 03:03:27 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								var le = require('letsencrypt').create({ server: 'staging' });
							 
						 
					
						
							
								
									
										
										
										
											2015-12-17 02:38:46 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-08-09 19:05:04 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								var opts = {
							 
						 
					
						
							
								
									
										
										
										
											2016-08-09 18:57:23 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  domains: ['example.com'], email: 'user@email .com', agreeTos: true
							 
						 
					
						
							
								
									
										
										
										
											2016-08-09 19:05:04 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								};
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								le.register(opts).then(function (certs) {
							 
						 
					
						
							
								
									
										
										
										
											2016-08-09 19:00:40 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  console.log(certs);
							 
						 
					
						
							
								
									
										
										
										
											2016-08-09 19:05:04 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  // privkey, cert, chain, expiresAt, issuedAt, subject, altnames
							 
						 
					
						
							
								
									
										
										
										
											2016-08-09 18:56:46 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}, function (err) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  console.error(err);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								});
							 
						 
					
						
							
								
									
										
										
										
											2016-08-05 03:20:19 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								You also need some sort of server to handle the acme challenge:
							 
						 
					
						
							
								
									
										
										
										
											2016-08-05 03:03:27 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-08-05 03:27:16 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```javascript
							 
						 
					
						
							
								
									
										
										
										
											2016-08-05 03:20:19 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								var app = express();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								app.use('/', le.middleware());
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Note: The `webrootPath`  string is a template.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Any occurance of `:hostname`  will be replaced
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								with the domain for which we are requested certificates.
							 
						 
					
						
							
								
									
										
										
										
											2015-12-12 22:16:02 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-08-05 03:03:27 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								### Useful Example
  
						 
					
						
							
								
									
										
										
										
											2015-12-12 22:16:02 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-08-05 03:03:27 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								The configuration consists of 3 components:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								*  Storage Backend (search npm for projects starting with 'le-store-') 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								*  ACME Challenge Handlers (search npm for projects starting with 'le-challenge-') 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								*  Letsencryt Config (this is all you) 
						 
					
						
							
								
									
										
										
										
											2015-12-12 13:11:05 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-12-13 01:04:44 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```javascript
							 
						 
					
						
							
								
									
										
										
										
											2016-08-05 03:03:27 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								'use strict';
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								var LE = require('letsencrypt');
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								var le;
							 
						 
					
						
							
								
									
										
										
										
											2015-12-12 15:38:14 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-12-12 22:06:36 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-08-05 03:03:27 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// Storage Backend
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								var leStore = require('le-store-certbot').create({
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  configDir: '~/letsencrypt/etc'                          // or /etc/letsencrypt or wherever
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								, debug: false
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								});
							 
						 
					
						
							
								
									
										
										
										
											2015-12-12 22:06:36 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-08-05 03:03:27 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// ACME Challenge Handlers
							 
						 
					
						
							
								
									
										
										
										
											2016-08-09 14:05:47 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								var leChallenge = require('le-challenge-fs').create({
							 
						 
					
						
							
								
									
										
										
										
											2016-08-05 03:03:27 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  webrootPath: '~/letsencrypt/var/'                       // or template string such as
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								, debug: false                                            // '/srv/www/:hostname/.well-known/acme-challenge'
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								});
							 
						 
					
						
							
								
									
										
										
										
											2015-12-12 22:06:36 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-08-05 03:03:27 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								function leAgree(opts, agreeCb) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  // opts = { email, domains, tosUrl }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  agreeCb(null, opts.tosUrl);
							 
						 
					
						
							
								
									
										
										
										
											2015-12-12 22:06:36 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
									
										
										
										
											2015-12-12 13:11:05 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-08-05 03:03:27 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								le = LE.create({
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  server: LE.stagingServerUrl                             // or LE.productionServerUrl
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								, store: leStore                                          // handles saving of config, accounts, and certificates
							 
						 
					
						
							
								
									
										
										
										
											2016-08-15 15:33:26 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								, challenges: { 'http-01': leChallenge }                  // handles /.well-known/acme-challege keys and tokens
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								, challengeType: 'http-01'                                // default to this challenge type
							 
						 
					
						
							
								
									
										
										
										
											2016-08-05 03:03:27 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								, agreeToTerms: leAgree                                   // hook to allow user to view and accept LE TOS
							 
						 
					
						
							
								
									
										
										
										
											2016-08-15 15:39:21 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								//, sni: require('le-sni-auto').create({})                // handles sni callback
							 
						 
					
						
							
								
									
										
										
										
											2016-08-05 03:03:27 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								, debug: false
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								});
							 
						 
					
						
							
								
									
										
										
										
											2015-12-13 01:04:12 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-12-12 13:11:05 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-08-05 03:03:27 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// If using express you should use the middleware
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// app.use('/', le.middleware());
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								//
							 
						 
					
						
							
								
									
										
										
										
											2016-08-09 16:12:16 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// Otherwise you should see the test file for usage of this:
							 
						 
					
						
							
								
									
										
										
										
											2016-08-15 15:33:26 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// le.challenges['http-01'].get(opts.domain, key, val, done)
							 
						 
					
						
							
								
									
										
										
										
											2015-12-12 13:11:05 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-08-05 03:03:27 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// Check in-memory cache of certificates for the named domain
							 
						 
					
						
							
								
									
										
										
										
											2016-08-09 16:12:16 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								le.check({ domains: [ 'example.com' ] }).then(function (results) {
							 
						 
					
						
							
								
									
										
										
										
											2016-08-05 03:03:27 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  if (results) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // we already have certificates
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    return;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  }
							 
						 
					
						
							
								
									
										
										
										
											2015-12-12 22:06:36 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-08-05 18:21:10 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-08-05 03:03:27 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  // Register Certificate manually
							 
						 
					
						
							
								
									
										
										
										
											2016-08-09 16:12:16 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  le.register({
							 
						 
					
						
							
								
									
										
										
										
											2016-08-05 18:21:10 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    domains: ['example.com']                                // CHANGE TO YOUR DOMAIN (list for SANS)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  , email: 'user@email .com'                                 // CHANGE TO YOUR EMAIL
							 
						 
					
						
							
								
									
										
										
										
											2016-08-06 01:34:34 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  , agreeTos: ''                                            // set to tosUrl string (or true) to pre-approve (and skip agreeToTerms)
							 
						 
					
						
							
								
									
										
										
										
											2016-08-05 18:21:10 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  , rsaKeySize: 2048                                        // 2048 or higher
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  , challengeType: 'http-01'                                // http-01, tls-sni-01, or dns-01
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  }).then(function (results) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    console.log('success');
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  }, function (err) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // Note: you must either use le.middleware() with express,
							 
						 
					
						
							
								
									
										
										
										
											2016-08-15 15:33:26 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    // manually use le.challenges['http-01'].get(opts, domain, key, val, done)
							 
						 
					
						
							
								
									
										
										
										
											2016-08-05 18:21:10 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    // or have a webserver running and responding
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // to /.well-known/acme-challenge at `webrootPath` 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    console.error('[Error]: node-letsencrypt/examples/standalone');
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    console.error(err.stack);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  });
							 
						 
					
						
							
								
									
										
										
										
											2015-12-12 22:06:36 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-08-05 03:03:27 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								});
							 
						 
					
						
							
								
									
										
										
										
											2015-12-12 13:11:05 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-08-05 03:03:27 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Here's what `results`  looks like:
							 
						 
					
						
							
								
									
										
										
										
											2015-12-12 22:06:36 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```javascript
							 
						 
					
						
							
								
									
										
										
										
											2016-08-05 03:03:27 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ privkey: ''     // PEM encoded private key
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								, cert: ''        // PEM encoded cert
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								, chain: ''       // PEM encoded intermediate cert
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								, issuedAt: 0     // notBefore date (in ms) parsed from cert
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								, expiresAt: 0    // notAfter date (in ms) parsed from cert
							 
						 
					
						
							
								
									
										
										
										
											2016-08-09 19:05:04 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								, subject: ''     // example.com
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								, altnames: []    // example.com,www.example.com
							 
						 
					
						
							
								
									
										
										
										
											2016-08-05 03:03:27 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
									
										
										
										
											2015-12-12 13:11:05 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-08-05 03:03:27 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								API
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								---
							 
						 
					
						
							
								
									
										
										
										
											2015-12-12 22:06:36 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-08-05 03:03:27 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								The full end-user API is exposed in the example above and includes all relevant options.
							 
						 
					
						
							
								
									
										
										
										
											2015-12-12 22:06:36 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-08-06 01:34:34 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
									
										
										
										
											2016-08-09 19:03:34 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								le.register(opts)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								le.check(opts)
							 
						 
					
						
							
								
									
										
										
										
											2016-08-06 01:34:34 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-08-05 03:03:27 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								### Helper Functions
  
						 
					
						
							
								
									
										
										
										
											2015-12-12 13:11:05 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-08-05 03:03:27 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								We do expose a few helper functions:
							 
						 
					
						
							
								
									
										
										
										
											2015-12-12 22:06:36 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-08-05 03:03:27 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								*  LE.validDomain(hostname) // returns '' or the hostname string if it's a valid ascii or punycode domain name 
						 
					
						
							
								
									
										
										
										
											2015-12-12 22:06:36 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-08-05 03:03:27 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								TODO fetch domain tld list
							 
						 
					
						
							
								
									
										
										
										
											2015-12-12 22:06:36 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-08-05 04:13:58 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								### Template Strings
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								The following variables will be tempalted in any strings passed to the options object:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								*  `~/`  replaced with `os.homedir()`  i.e. `/Users/aj`  
						 
					
						
							
								
									
										
										
										
											2016-08-08 18:10:23 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								*  `:hostname`  replaced with the first domain in the list i.e. `example.com`  
						 
					
						
							
								
									
										
										
										
											2016-08-05 04:13:58 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-08-05 03:03:27 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Developer API
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								-------------
							 
						 
					
						
							
								
									
										
										
										
											2015-12-12 22:06:36 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-08-05 03:03:27 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								If you are developing an `le-store-*`  or `le-challenge-*`  plugin you need to be aware of
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								additional internal API expectations.
							 
						 
					
						
							
								
									
										
										
										
											2015-12-12 22:06:36 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-08-05 03:03:27 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								**IMPORTANT**:
							 
						 
					
						
							
								
									
										
										
										
											2015-12-12 22:06:36 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-08-05 03:03:27 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Use `v2.0.0`  as your initial version - NOT v0.1.0 and NOT v1.0.0 and NOT v3.0.0.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								This is to indicate that your module is compatible with v2.x of node-letsencrypt.
							 
						 
					
						
							
								
									
										
										
										
											2015-12-13 05:03:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-08-05 03:03:27 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Since the public API for your module is defined by node-letsencrypt the major version
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								should be kept in sync.
							 
						 
					
						
							
								
									
										
										
										
											2015-12-13 05:03:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-08-05 03:03:27 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								### store implementation
  
						 
					
						
							
								
									
										
										
										
											2015-12-12 13:11:05 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-08-12 15:25:59 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								See < https: / / github . com / Daplie / le-store-SPEC > 
							 
						 
					
						
							
								
									
										
										
										
											2016-08-09 16:40:35 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								*  getOptions() 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								*  accounts. 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  *  checkKeypair(opts, cb)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  *  check(opts, cb)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  *  setKeypair(opts, keypair, cb)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  *  set(opts, reg, cb)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								*  certificates. 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  *  checkKeypair(opts, cb)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  *  check(opts, cb)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  *  setKeypair(opts, keypair, cb)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  *  set(opts, reg, cb)
							 
						 
					
						
							
								
									
										
										
										
											2016-08-05 03:03:27 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								### challenge implementation
  
						 
					
						
							
								
									
										
										
										
											2015-12-12 13:11:05 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-08-09 16:40:35 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								See https://github.com/Daplie/le-challenge-fs
							 
						 
					
						
							
								
									
										
										
										
											2015-12-12 13:11:05 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-08-09 16:40:35 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								*  `.set(opts, domain, key, value, cb);`          // opts will be saved with domain/key 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								*  `.get(opts, domain, key, cb);`                 // opts will be retrieved by domain/key 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								*  `.remove(opts, domain, key, cb);`              // opts will be retrieved by domain/key 
						 
					
						
							
								
									
										
										
										
											2015-12-12 13:11:05 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-12-13 03:09:06 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Change History
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								==============
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-08-09 16:40:35 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								*  v2.0.2 - Aug 9th 2016 update readme 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								*  v2.0.1 - Aug 9th 2016 
						 
					
						
							
								
									
										
										
										
											2016-08-05 03:03:27 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  *  major refactor
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  *  simplified API
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  *  modular pluigns
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  *  knock out bugs
							 
						 
					
						
							
								
									
										
										
										
											2016-08-03 23:13:40 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								*  v1.5.0 now using letiny-core v2.0.0 and rsa-compat 
						 
					
						
							
								
									
										
										
										
											2016-04-18 17:01:35 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								*  v1.4.x I can't remember... but it's better! 
						 
					
						
							
								
									
										
										
										
											2015-12-16 01:19:08 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								*  v1.1.0 Added letiny-core, removed node-letsencrypt-python 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								*  v1.0.2 Works with node-letsencrypt-python 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								*  v1.0.0 Thar be dragons 
						 
					
						
							
								
									
										
										
										
											2015-12-13 03:09:06 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-12-11 03:23:47 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								LICENSE
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								=======
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Dual-licensed MIT and Apache-2.0
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								See LICENSE