closer
This commit is contained in:
		
							parent
							
								
									310caf159a
								
							
						
					
					
						commit
						e50782b85a
					
				| @ -2,10 +2,14 @@ | |||||||
| 
 | 
 | ||||||
| module.exports.create = function (opts) { | module.exports.create = function (opts) { | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|   opts.workerSniCallback = require('le-sni-auto').create({ |   opts.workerSniCallback = require('le-sni-auto').create({ | ||||||
|     getCertificates: function (domain, certs, cb) { |     notBefore: opts.notBefore || (10 * 24 * 60 * 60 * 1000) | ||||||
|  |   , notAfter: opts.notAfter || (5 * 24 * 60 * 60 * 1000) | ||||||
|  |   , getCertificates: function (domain, certs, cb) { | ||||||
|       opts.approveDomains(domain, certs, function (err, certs) { |       opts.approveDomains(domain, certs, function (err, certs) { | ||||||
|         process.send({ type: 'LE_REQUEST', domain: domain, options: { domains: [domain] } certs: certs }); |         process.send({ type: 'LE_REQUEST', domain: domain, options: { domains: [domain] }, certs: certs }); | ||||||
| 
 | 
 | ||||||
|         process.on('message', function (msg) { |         process.on('message', function (msg) { | ||||||
|           if (msg.domain === domain) { |           if (msg.domain === domain) { | ||||||
| @ -16,5 +20,24 @@ module.exports.create = function (opts) { | |||||||
|     } |     } | ||||||
|   }).sniCallback; |   }).sniCallback; | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |   opts.httpsOptions = require('localhost.daplie.com-certificates').merge({ SNICallback: opts.workerSniCallback }); | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |   opts.challenge = { | ||||||
|  |     get: opts.getChallenge | ||||||
|  |       || (opts.challenge && opts.challenge.get) | ||||||
|  |       || require('le-challenge-fs').create({ webrootPath: opts.webrootPath }).get | ||||||
|  |   }; | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |   // opts.challenge.get, opts.acmeChallengePrefix
 | ||||||
|  |   opts.middleware = require('letsencrypt/lib/middleware').create(opts); | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|   return opts; |   return opts; | ||||||
| }; | }; | ||||||
|  | |||||||
							
								
								
									
										12
									
								
								serve.js
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								serve.js
									
									
									
									
									
								
							| @ -21,7 +21,7 @@ function runMaster() { | |||||||
|       //
 |       //
 | ||||||
|       // Since we implement it in the worker (below) in this example
 |       // Since we implement it in the worker (below) in this example
 | ||||||
|       // we'll give it an immediate approval here in the master
 |       // we'll give it an immediate approval here in the master
 | ||||||
|       var results = { options: { domains: [domain] }, certs: certs }; |       var results = { domain: domain, options: { domains: [domain] }, certs: certs }; | ||||||
|       cb(null, results); |       cb(null, results); | ||||||
|     } |     } | ||||||
|   }); |   }); | ||||||
| @ -53,7 +53,7 @@ function runWorker() { | |||||||
|   , approveDomains: function (domain, certs, cb) { |   , approveDomains: function (domain, certs, cb) { | ||||||
|       // opts = { domains, email, agreeTos, tosUrl }
 |       // opts = { domains, email, agreeTos, tosUrl }
 | ||||||
|       // certs = { subject, altnames, expiresAt, issuedAt }
 |       // certs = { subject, altnames, expiresAt, issuedAt }
 | ||||||
|       var results = { options: { domains: [domain] }, certs: certs }; |       var results = { domain: domain, options: { domains: [domain] }, certs: certs }; | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| @ -81,8 +81,12 @@ function runWorker() { | |||||||
|     res.end("Hello, World!"); |     res.end("Hello, World!"); | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   var plainServer = require('http').createServer(worker.handleAcmeOrRedirectToHttps()); | 
 | ||||||
|   var server = require('https').createServer(worker.httpsOptions, worker.handleAcmeOrUse(app)); |   // worker.handleAcmeOrRedirectToHttps()
 | ||||||
|  |   // worker.handleAcmeOrUse(app)
 | ||||||
|  |   var redirectHttps = require('redirect-https')(); | ||||||
|  |   var plainServer = require('http').createServer(worker.middleware(redirectHttps)); | ||||||
|  |   var server = require('https').createServer(worker.httpsOptions, worker.middleware(app)); | ||||||
|   plainServer.listen(80); |   plainServer.listen(80); | ||||||
|   server.listen(443); |   server.listen(443); | ||||||
| } | } | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user