forked from root/acme.js
		
	update compat to allow testing dns
This commit is contained in:
		
							parent
							
								
									8117b1fd66
								
							
						
					
					
						commit
						668e2bb0ac
					
				
							
								
								
									
										6
									
								
								node.js
									
									
									
									
									
								
							
							
						
						
									
										6
									
								
								node.js
									
									
									
									
									
								
							@ -416,13 +416,17 @@ ACME._postChallenge = function (me, options, identifier, ch) {
 | 
			
		||||
      if (1 === options.setChallenge.length) {
 | 
			
		||||
        options.setChallenge(auth).then(testChallenge).then(resolve, reject);
 | 
			
		||||
      } else if (2 === options.setChallenge.length) {
 | 
			
		||||
        options.setChallenge(auth, function(err) {
 | 
			
		||||
        var challengeCb = function (err) {
 | 
			
		||||
          if(err) {
 | 
			
		||||
            reject(err);
 | 
			
		||||
          } else {
 | 
			
		||||
            testChallenge().then(resolve, reject);
 | 
			
		||||
          }
 | 
			
		||||
        };
 | 
			
		||||
        Object.keys(auth).forEach(function (key) {
 | 
			
		||||
          challengeCb[key] = auth[key];
 | 
			
		||||
        });
 | 
			
		||||
        options.setChallenge(auth, challengeCb);
 | 
			
		||||
      } else {
 | 
			
		||||
        options.setChallenge(identifier.value, ch.token, keyAuthorization, function(err) {
 | 
			
		||||
          if(err) {
 | 
			
		||||
 | 
			
		||||
@ -1,6 +1,6 @@
 | 
			
		||||
{
 | 
			
		||||
  "name": "acme-v2",
 | 
			
		||||
  "version": "1.1.0",
 | 
			
		||||
  "version": "1.1.1",
 | 
			
		||||
  "description": "Free SSL. A framework for building Let's Encrypt v2 clients, and other ACME v2 (draft 11) clients. Successor to le-acme-core.js",
 | 
			
		||||
  "homepage": "https://git.coolaj86.com/coolaj86/acme-v2.js",
 | 
			
		||||
  "main": "node.js",
 | 
			
		||||
 | 
			
		||||
@ -12,10 +12,23 @@ module.exports.run = function (directoryUrl, RSA, web, chType, email, accountKey
 | 
			
		||||
        agree(null, tosUrl);
 | 
			
		||||
      }
 | 
			
		||||
    , setChallenge: function (hostname, token, val, cb) {
 | 
			
		||||
        var pathname = hostname + acme2.acmeChallengePrefix + token;
 | 
			
		||||
        console.log("Put the string '" + val + "' into a file at '" + pathname + "'");
 | 
			
		||||
        console.log("echo '" + val + "' > '" + pathname + "'");
 | 
			
		||||
        var pathname;
 | 
			
		||||
 | 
			
		||||
        if ('http-01' === cb.type) {
 | 
			
		||||
          pathname = hostname + acme2.acmeChallengePrefix + token;
 | 
			
		||||
          console.log("Put the string '" + val /*keyAuthorization*/ + "' into a file at '" + pathname + "'");
 | 
			
		||||
          console.log("echo '" + val /*keyAuthorization*/ + "' > '" + pathname + "'");
 | 
			
		||||
          console.log("\nThen hit the 'any' key to continue...");
 | 
			
		||||
        } else if ('dns-01' === cb.type) {
 | 
			
		||||
          // forwards-backwards compat
 | 
			
		||||
          pathname = acme2.challengePrefixes['dns-01'] + "." + hostname.replace(/^\*\./, '');
 | 
			
		||||
          console.log("Put the string '" + cb.dnsAuthorization + "' into the TXT record '" + pathname + "'");
 | 
			
		||||
          console.log("dig TXT " + pathname + " '" + cb.dnsAuthorization + "'");
 | 
			
		||||
          console.log("\nThen hit the 'any' key to continue...");
 | 
			
		||||
        } else {
 | 
			
		||||
          cb(new Error("[acme-v2] unrecognized challenge type"));
 | 
			
		||||
          return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        function onAny() {
 | 
			
		||||
          console.log("'any' key was hit");
 | 
			
		||||
 | 
			
		||||
@ -35,9 +35,9 @@ module.exports.run = function run(directoryUrl, RSA, web, chType, email, account
 | 
			
		||||
            console.log("Put the string '" + opts.keyAuthorization + "' into a file at '" + pathname + "'");
 | 
			
		||||
            console.log("echo '" + opts.keyAuthorization + "' > '" + pathname + "'");
 | 
			
		||||
          } else if ('dns-01' === opts.type) {
 | 
			
		||||
            pathname = acme2.challengePrefixes['dns-01'] + "." + opts.hostname.replace(/^\*\./, '');;
 | 
			
		||||
            pathname = acme2.challengePrefixes['dns-01'] + "." + opts.hostname.replace(/^\*\./, '');
 | 
			
		||||
            console.log("Put the string '" + opts.dnsAuthorization + "' into the TXT record '" + pathname + "'");
 | 
			
		||||
            console.log("ddig TXT " + pathname + " '" + opts.dnsAuthorization + "'");
 | 
			
		||||
            console.log("dig TXT " + pathname + " '" + opts.dnsAuthorization + "'");
 | 
			
		||||
          } else {
 | 
			
		||||
            reject(new Error("[acme-v2] unrecognized challenge type"));
 | 
			
		||||
            return;
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user