mirror of
				https://git.coolaj86.com/coolaj86/greenlock-cli.js
				synced 2025-11-04 11:02:47 +00:00 
			
		
		
		
	update handlers to le v2.x style
This commit is contained in:
		
							parent
							
								
									093c85ef91
								
							
						
					
					
						commit
						9ec3ed7975
					
				@ -9,9 +9,12 @@ module.exports.create = function (defaults) {
 | 
			
		||||
    //
 | 
			
		||||
    // set,get,remove challenges
 | 
			
		||||
    //
 | 
			
		||||
    _challenges: {}
 | 
			
		||||
  , setChallenge: function (args, key, value, cb) {
 | 
			
		||||
      var challengePath = path.join(defaults.webrootPath, '.well-known', 'acme-challenge');
 | 
			
		||||
    getOptions: function () {
 | 
			
		||||
      return { webrootPath: defaults.webrootPath };
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  , set: function (args, domain, token, secret, cb) {
 | 
			
		||||
      var challengePath = path.join(args.webrootPath || defaults.webrootPath, '.well-known', 'acme-challenge');
 | 
			
		||||
      mkdirp(challengePath, function (err) {
 | 
			
		||||
        if (err) {
 | 
			
		||||
          console.error("Could not create --webroot-path '" + challengePath + "':", err.code);
 | 
			
		||||
@ -20,11 +23,11 @@ module.exports.create = function (defaults) {
 | 
			
		||||
          return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        var keyfile = path.join(challengePath, key);
 | 
			
		||||
        var tokenfile = path.join(challengePath, token);
 | 
			
		||||
 | 
			
		||||
        fs.writeFile(keyfile, value, 'utf8', function (err) {
 | 
			
		||||
        fs.writeFile(tokenfile, secret, 'utf8', function (err) {
 | 
			
		||||
          if (err) {
 | 
			
		||||
            console.error("Could not write '" + keyfile + "':", err.code);
 | 
			
		||||
            console.error("Could not write '" + tokenfile + "':", err.code);
 | 
			
		||||
            cb(err);
 | 
			
		||||
            return;
 | 
			
		||||
          }
 | 
			
		||||
@ -33,14 +36,19 @@ module.exports.create = function (defaults) {
 | 
			
		||||
        });
 | 
			
		||||
      });
 | 
			
		||||
    }
 | 
			
		||||
  // handled as file read by web server
 | 
			
		||||
  // , getChallenge: function (args, key, cb) {}
 | 
			
		||||
  , removeChallenge: function (args, key, cb) {
 | 
			
		||||
      var keyfile = path.join(defaults.webrootPath, '.well-known', 'acme-challenge', key);
 | 
			
		||||
 | 
			
		||||
      fs.unlink(keyfile, function (err) {
 | 
			
		||||
    // handled as file read by web server
 | 
			
		||||
  , get: function (args, domain, token, cb) {
 | 
			
		||||
      // see https://github.com/Daplie/node-letsencrypt/issues/41
 | 
			
		||||
      cb(new Error("get not implemented (on purpose) in le-cli/lib/webroot.js"));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  , remove: function (args, domain, token, cb) {
 | 
			
		||||
      var tokenfile = path.join(args.webrootPath || defaults.webrootPath, '.well-known', 'acme-challenge', token);
 | 
			
		||||
 | 
			
		||||
      fs.unlink(tokenfile, function (err) {
 | 
			
		||||
        if (err) {
 | 
			
		||||
          console.error("Could not unlink '" + keyfile + "':", err.code);
 | 
			
		||||
          console.error("Could not unlink '" + tokenfile + "':", err.code);
 | 
			
		||||
          cb(err);
 | 
			
		||||
          return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user