| 
									
										
										
										
											2019-10-20 02:51:19 -06:00
										 |  |  | 'use strict'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | require('dotenv').config(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | var Greenlock = require('../'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | var subject = process.env.BASE_DOMAIN; | 
					
						
							|  |  |  | var altnames = [subject, '*.' + subject, 'foo.bar.' + subject]; | 
					
						
							|  |  |  | var email = process.env.SUBSCRIBER_EMAIL; | 
					
						
							|  |  |  | var challenge = JSON.parse(process.env.CHALLENGE_OPTIONS); | 
					
						
							| 
									
										
										
										
											2019-10-20 03:17:19 -06:00
										 |  |  | challenge.module = process.env.CHALLENGE_PLUGIN; | 
					
						
							| 
									
										
										
										
											2019-10-20 02:51:19 -06:00
										 |  |  | 
 | 
					
						
							|  |  |  | var greenlock = Greenlock.create({ | 
					
						
							| 
									
										
										
										
											2019-10-31 16:26:18 -06:00
										 |  |  |     packageAgent: 'Greenlock_Test/v0', | 
					
						
							|  |  |  |     maintainerEmail: email, | 
					
						
							|  |  |  |     staging: true, | 
					
						
							|  |  |  |     manager: require('greenlock-manager-fs').create({ | 
					
						
							|  |  |  |         //configFile: '~/.config/greenlock/certs.json',
 | 
					
						
							|  |  |  |     }) | 
					
						
							| 
									
										
										
										
											2019-10-20 02:51:19 -06:00
										 |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-31 05:49:37 -06:00
										 |  |  | greenlock.manager | 
					
						
							| 
									
										
										
										
											2019-10-31 16:26:18 -06:00
										 |  |  |     .defaults({ | 
					
						
							|  |  |  |         agreeToTerms: true, | 
					
						
							|  |  |  |         subscriberEmail: email, | 
					
						
							|  |  |  |         challenges: { | 
					
						
							|  |  |  |             'dns-01': challenge | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         //store: args.storeOpts,
 | 
					
						
							|  |  |  |         //renewOffset: args.renewOffset || '30d',
 | 
					
						
							|  |  |  |         //renewStagger: '1d'
 | 
					
						
							|  |  |  |     }) | 
					
						
							|  |  |  |     .then(function() { | 
					
						
							|  |  |  |         return greenlock | 
					
						
							|  |  |  |             .add({ | 
					
						
							|  |  |  |                 subject: subject, | 
					
						
							|  |  |  |                 altnames: altnames, | 
					
						
							|  |  |  |                 subscriberEmail: email | 
					
						
							|  |  |  |             }) | 
					
						
							|  |  |  |             .then(function() { | 
					
						
							|  |  |  |                 return greenlock | 
					
						
							|  |  |  |                     .get({ servername: subject }) | 
					
						
							|  |  |  |                     .then(function(pems) { | 
					
						
							|  |  |  |                         if (pems && pems.privkey && pems.cert && pems.chain) { | 
					
						
							|  |  |  |                             console.info('Success'); | 
					
						
							|  |  |  |                         } | 
					
						
							|  |  |  |                         //console.log(pems);
 | 
					
						
							|  |  |  |                     }); | 
					
						
							|  |  |  |             }); | 
					
						
							|  |  |  |     }) | 
					
						
							|  |  |  |     .catch(function(e) { | 
					
						
							|  |  |  |         console.error('Big bad error:', e.code); | 
					
						
							|  |  |  |         console.error(e); | 
					
						
							|  |  |  |     }); |