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-04-22 12:21:58 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								| **letsencrypt**  (library)
							 
						 
					
						
							
								
									
										
										
										
											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-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-05 03:27:16 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								letsencrypt (v2)
							 
						 
					
						
							
								
									
										
										
										
											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 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-12-22 12:13:30 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  *  [Automatic HTTPS with ExpressJS ](https://github.com/Daplie/letsencrypt-express )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  *  [Automatic live renewal ](https://github.com/Daplie/letsencrypt-express#how-automatic )
							 
						 
					
						
							
								
									
										
										
										
											2015-12-13 08:05:24 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  *  On-the-fly HTTPS certificates for Dynamic DNS (in-process, no server restart)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  *  Works with node cluster out of the box
							 
						 
					
						
							
								
									
										
										
										
											2015-12-22 12:13:30 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  *  usable [via commandline ](https://github.com/Daplie/letsencrypt-cli ) as well
							 
						 
					
						
							
								
									
										
										
										
											2015-12-12 22:40:03 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  *  Free SSL (HTTPS Certificates for TLS)
							 
						 
					
						
							
								
									
										
										
										
											2015-12-13 08:05:24 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  *  [90-day certificates ](https://letsencrypt.org/2015/11/09/why-90-days.html )
							 
						 
					
						
							
								
									
										
										
										
											2015-12-12 13:11:05 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-12-13 01:04:44 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								**See Also**
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								*  [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 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-04-18 17:01:35 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								STOP
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								====
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-08-05 03:20:19 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								>  **These aren't 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
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								[**letsencrypt-express** ](https://github.com/Daplie/letsencrypt-express ).
							 
						 
					
						
							
								
									
										
										
										
											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 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-08-05 03:03:27 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								CONTINUE
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								========
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								If you're sure you're at the right place, here's what you need to know now:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-12-12 13:11:05 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Install
							 
						 
					
						
							
								
									
										
										
										
											2016-08-05 03:03:27 -04: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 )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								and the default challenger is [`le-challenge-fs` ](https://github.com/Daplie/le-challenge-fs ).
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-12-12 13:11:05 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```bash
							 
						 
					
						
							
								
									
										
										
										
											2016-08-05 03:03:27 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								npm install --save letsencrypt@2 .x
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								npm install --save le-store-certbot@2 .x
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								npm install --save le-challenge-fs@2 .x
							 
						 
					
						
							
								
									
										
										
										
											2015-12-12 13:11:05 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-12-13 01:04:44 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Usage
							 
						 
					
						
							
								
									
										
										
										
											2016-08-05 03:03:27 -04: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-05 03:03:27 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Against my better judgement I'm providing a terribly oversimplified exmaple
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								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-05 03:20:19 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								le.register(
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  { domains: ['example.com'], email: 'user@email .com', agreeTos: true }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								, function (err, results) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    console.log(err, results);
							 
						 
					
						
							
								
									
										
										
										
											2015-12-13 01:04:44 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  }
							 
						 
					
						
							
								
									
										
										
										
											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
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								var leChallenger = require('le-challenge-fs').create({
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  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
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								, challenger: leChallenger                                // handles /.well-known/acme-challege keys and tokens
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								, agreeToTerms: leAgree                                   // hook to allow user to view and accept LE TOS
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								, 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());
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								//
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// Otherwise you should use the wrapped getChallenge:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// le.getChallenge(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
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								le.exists({ domain: 'example.com' }).then(function (results) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  if (results) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // we already have certificates
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    return;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  }
							 
						 
					
						
							
								
									
										
										
										
											2015-12-12 22:06:36 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-08-05 03:03:27 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  // Register Certificate manually
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  le.register(
							 
						 
					
						
							
								
									
										
										
										
											2015-12-12 22:06:36 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-08-05 03:03:27 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    { domains: ['example.com']                                // CHANGE TO YOUR DOMAIN (list for SANS)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    , email: 'user@email .com'                                 // CHANGE TO YOUR EMAIL
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    , agreeTos: ''                                            // set to tosUrl string to pre-approve (and skip agreeToTerms)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    , rsaKeySize: 2048                                        // 1024 or 2048
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    , challengeType: 'http-01'                                // http-01, tls-sni-01, or dns-01
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
									
										
										
										
											2015-12-12 22:06:36 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-08-05 03:03:27 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  , function (err, results) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      if (err) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // Note: you must either use le.middleware() with express,
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // manually use le.getChallenge(domain, key, val, done)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // 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);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      }
							 
						 
					
						
							
								
									
										
										
										
											2015-12-12 22:06:36 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-08-05 03:03:27 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      console.log('success');
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
									
										
										
										
											2015-12-12 22:06:36 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-08-05 03:03:27 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  );
							 
						 
					
						
							
								
									
										
										
										
											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
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								, fullchain: ''   // cert + chain
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								, issuedAt: 0     // notBefore date (in ms) parsed from cert
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								, expiresAt: 0    // notAfter date (in ms) parsed from cert
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
									
										
										
										
											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-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`  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								*  `:hostname`  replaced with the domain i.e. `example.com`  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								*  `:config`  replaced with `configDir`  i.e. `~/letsencrypt/etc`  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								*  `:server`  replaced with the hostname + pathname of the acme server api 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											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-05 03:03:27 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								TODO double check and finish
							 
						 
					
						
							
								
									
										
										
										
											2015-12-12 13:11:05 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-08-05 03:03:27 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								*  accounts 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  *  accounts.byDomain
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  *  accounts.all
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  *  accounts.get
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  *  accounts.exists
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								*  certs 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  *  certs.byDomain
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  *  certs.all
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  *  certs.get
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  *  certs.exists
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								### challenge implementation
  
						 
					
						
							
								
									
										
										
										
											2015-12-12 13:11:05 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-08-05 03:03:27 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								TODO finish
							 
						 
					
						
							
								
									
										
										
										
											2015-12-12 13:11:05 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-08-05 03:03:27 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								*  setChallenge(opts, domain, key, value, done);   // opts will be saved with domain/key 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								*  getChallenge(domain, key, done);                // opts will be retrieved by domain/key 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								*  removeChallenge(domain, key, done);             // 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-05 03:03:27 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								*  v2.0.0 - Aug 5th 2016 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  *  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