Compare commits
	
		
			1 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 31c1f87f93 | 
							
								
								
									
										17
									
								
								index.js
									
									
									
									
									
								
							
							
						
						
									
										17
									
								
								index.js
									
									
									
									
									
								
							@ -13,19 +13,11 @@ var defaults = {
 | 
				
			|||||||
  // just to account for clock skew really
 | 
					  // just to account for clock skew really
 | 
				
			||||||
, _dropDead: 5 * MIN
 | 
					, _dropDead: 5 * MIN
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
var promisify = require('util').promisify;
 | 
					 | 
				
			||||||
if (!promisify) {
 | 
					 | 
				
			||||||
  try {
 | 
					 | 
				
			||||||
    promisify = require('bluebird').promisify;
 | 
					 | 
				
			||||||
  } catch(e) {
 | 
					 | 
				
			||||||
    console.error("You're running an older version of node that doesn't have 'promisify'. Please run 'npm install bluebird --save'.");
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
// autoSni = { renewWithin, renewBy, getCertificates, tlsOptions, _dbg_now }
 | 
					// autoSni = { renewWithin, renewBy, getCertificates, tlsOptions, _dbg_now }
 | 
				
			||||||
module.exports.create = function (autoSni) {
 | 
					module.exports.create = function (autoSni) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (!autoSni.getCertificatesAsync) { autoSni.getCertificatesAsync = promisify(autoSni.getCertificates); }
 | 
					  if (!autoSni.getCertificatesAsync) { autoSni.getCertificatesAsync = require('bluebird').promisify(autoSni.getCertificates); }
 | 
				
			||||||
  if (!autoSni.renewWithin) { autoSni.renewWithin = autoSni.notBefore || defaults.renewWithin; }
 | 
					  if (!autoSni.renewWithin) { autoSni.renewWithin = autoSni.notBefore || defaults.renewWithin; }
 | 
				
			||||||
  if (autoSni.renewWithin < defaults._renewWithinMin) {
 | 
					  if (autoSni.renewWithin < defaults._renewWithinMin) {
 | 
				
			||||||
    throw new Error("options.renewWithin should be at least " + (defaults._renewWithinMin / DAY) + " days");
 | 
					    throw new Error("options.renewWithin should be at least " + (defaults._renewWithinMin / DAY) + " days");
 | 
				
			||||||
@ -131,7 +123,7 @@ module.exports.create = function (autoSni) {
 | 
				
			|||||||
      else if (certMeta.then) {
 | 
					      else if (certMeta.then) {
 | 
				
			||||||
        //log(autoSni.debug, "PROMISED CERT", domain);
 | 
					        //log(autoSni.debug, "PROMISED CERT", domain);
 | 
				
			||||||
        // we are already getting a cert
 | 
					        // we are already getting a cert
 | 
				
			||||||
        promise = certMeta;
 | 
					        promise = certMeta
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      else if (now >= certMeta.expiresNear) {
 | 
					      else if (now >= certMeta.expiresNear) {
 | 
				
			||||||
        //log(autoSni.debug, "EXPIRED CERT");
 | 
					        //log(autoSni.debug, "EXPIRED CERT");
 | 
				
			||||||
@ -146,10 +138,7 @@ module.exports.create = function (autoSni) {
 | 
				
			|||||||
          // give the cert some time (2-5 min) to be validated and replaced before trying again
 | 
					          // give the cert some time (2-5 min) to be validated and replaced before trying again
 | 
				
			||||||
          certMeta.renewAt = (autoSni._dbg_now || Date.now()) + (2 * MIN) + (3 * MIN * Math.random());
 | 
					          certMeta.renewAt = (autoSni._dbg_now || Date.now()) + (2 * MIN) + (3 * MIN * Math.random());
 | 
				
			||||||
          // let the update happen in the background
 | 
					          // let the update happen in the background
 | 
				
			||||||
          autoSni.getCertificatesAsync(domain, certMeta.certs).then(autoSni.cacheCerts, function (error) {
 | 
					          autoSni.getCertificatesAsync(domain, certMeta.certs).then(autoSni.cacheCerts);
 | 
				
			||||||
            // console.error('ERROR in le-sni-auto:');
 | 
					 | 
				
			||||||
            // console.error(err.stack || err);
 | 
					 | 
				
			||||||
          })
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // return the valid cert right away
 | 
					        // return the valid cert right away
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										5
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										5
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							@ -1,5 +0,0 @@
 | 
				
			|||||||
{
 | 
					 | 
				
			||||||
  "name": "le-sni-auto",
 | 
					 | 
				
			||||||
  "version": "2.1.9",
 | 
					 | 
				
			||||||
  "lockfileVersion": 1
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
@ -1,6 +1,6 @@
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
  "name": "le-sni-auto",
 | 
					  "name": "le-sni-auto",
 | 
				
			||||||
  "version": "2.1.9",
 | 
					  "version": "2.1.7",
 | 
				
			||||||
  "description": "An auto-sni strategy for registering and renewing letsencrypt certificates using SNICallback",
 | 
					  "description": "An auto-sni strategy for registering and renewing letsencrypt certificates using SNICallback",
 | 
				
			||||||
  "homepage": "https://git.coolaj86.com/coolaj86/le-sni-auto.js",
 | 
					  "homepage": "https://git.coolaj86.com/coolaj86/le-sni-auto.js",
 | 
				
			||||||
  "main": "index.js",
 | 
					  "main": "index.js",
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user