xyzURL -> xyzUrl
This commit is contained in:
		
							parent
							
								
									5765aa6974
								
							
						
					
					
						commit
						1bb9de56b0
					
				@ -16,7 +16,7 @@ var Acme = require('./acme-client');
 | 
				
			|||||||
function getCert(options, cb) {
 | 
					function getCert(options, cb) {
 | 
				
			||||||
  var state={
 | 
					  var state={
 | 
				
			||||||
    validatedDomains:[],
 | 
					    validatedDomains:[],
 | 
				
			||||||
    validAuthorizationURLs:[]
 | 
					    validAuthorizationUrls:[]
 | 
				
			||||||
  };
 | 
					  };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (!options.accountPrivateKeyPem) {
 | 
					  if (!options.accountPrivateKeyPem) {
 | 
				
			||||||
@ -85,8 +85,8 @@ function getCert(options, cb) {
 | 
				
			|||||||
      return handleErr(err, 'Server didn\'t provide information to proceed (2)');
 | 
					      return handleErr(err, 'Server didn\'t provide information to proceed (2)');
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    state.authorizationURL=res.headers.location;
 | 
					    state.authorizationUrl=res.headers.location;
 | 
				
			||||||
    state.newCertificateURL=links.next;
 | 
					    state.newCertificateUrl=links.next;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    authz=JSON.parse(body);
 | 
					    authz=JSON.parse(body);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -101,13 +101,13 @@ function getCert(options, cb) {
 | 
				
			|||||||
    thumbprint=cryptoUtil.thumbprint(state.accountKeyPair.publicKey);
 | 
					    thumbprint=cryptoUtil.thumbprint(state.accountKeyPair.publicKey);
 | 
				
			||||||
    keyAuthorization=challenge.token+'.'+thumbprint;
 | 
					    keyAuthorization=challenge.token+'.'+thumbprint;
 | 
				
			||||||
    challengePath='.well-known/acme-challenge/'+challenge.token;
 | 
					    challengePath='.well-known/acme-challenge/'+challenge.token;
 | 
				
			||||||
    state.responseURL=challenge.uri;
 | 
					    state.responseUrl=challenge.uri;
 | 
				
			||||||
    state.path=challengePath;
 | 
					    state.path=challengePath;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    options.setChallenge(state.domain, '/'+challengePath, keyAuthorization, challengeDone);
 | 
					    options.setChallenge(state.domain, '/'+challengePath, keyAuthorization, challengeDone);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    function challengeDone() {
 | 
					    function challengeDone() {
 | 
				
			||||||
      state.acme.post(state.responseURL, {
 | 
					      state.acme.post(state.responseUrl, {
 | 
				
			||||||
        resource:'challenge',
 | 
					        resource:'challenge',
 | 
				
			||||||
        keyAuthorization:keyAuthorization
 | 
					        keyAuthorization:keyAuthorization
 | 
				
			||||||
      }, function(err, res, body) {
 | 
					      }, function(err, res, body) {
 | 
				
			||||||
@ -132,14 +132,14 @@ function getCert(options, cb) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    if (authz.status==='pending') {
 | 
					    if (authz.status==='pending') {
 | 
				
			||||||
      setTimeout(function() {
 | 
					      setTimeout(function() {
 | 
				
			||||||
        request.get(state.authorizationURL, {}, function(err, res, body) {
 | 
					        request.get(state.authorizationUrl, {}, function(err, res, body) {
 | 
				
			||||||
          ensureValidation(err, res, body, unlink);
 | 
					          ensureValidation(err, res, body, unlink);
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
      }, 1000);
 | 
					      }, 1000);
 | 
				
			||||||
    } else if (authz.status==='valid') {
 | 
					    } else if (authz.status==='valid') {
 | 
				
			||||||
      log('Validating domain ... done');
 | 
					      log('Validating domain ... done');
 | 
				
			||||||
      state.validatedDomains.push(state.domain);
 | 
					      state.validatedDomains.push(state.domain);
 | 
				
			||||||
      state.validAuthorizationURLs.push(state.authorizationURL);
 | 
					      state.validAuthorizationUrls.push(state.authorizationUrl);
 | 
				
			||||||
      unlink();
 | 
					      unlink();
 | 
				
			||||||
      nextDomain();
 | 
					      nextDomain();
 | 
				
			||||||
    } else if (authz.status==='invalid') {
 | 
					    } else if (authz.status==='invalid') {
 | 
				
			||||||
@ -154,15 +154,15 @@ function getCert(options, cb) {
 | 
				
			|||||||
  function getCertificate() {
 | 
					  function getCertificate() {
 | 
				
			||||||
    var csr=cryptoUtil.generateCSR(state.certPrivateKey, state.validatedDomains);
 | 
					    var csr=cryptoUtil.generateCSR(state.certPrivateKey, state.validatedDomains);
 | 
				
			||||||
    log('Requesting certificate...');
 | 
					    log('Requesting certificate...');
 | 
				
			||||||
    state.acme.post(state.newCertificateURL, {
 | 
					    state.acme.post(state.newCertificateUrl, {
 | 
				
			||||||
      resource:'new-cert',
 | 
					      resource:'new-cert',
 | 
				
			||||||
      csr:csr,
 | 
					      csr:csr,
 | 
				
			||||||
      authorizations:state.validAuthorizationURLs
 | 
					      authorizations:state.validAuthorizationUrls
 | 
				
			||||||
    }, downloadCertificate);
 | 
					    }, downloadCertificate);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  function downloadCertificate(err, res, body) {
 | 
					  function downloadCertificate(err, res, body) {
 | 
				
			||||||
    var links, certURL;
 | 
					    var links, certUrl;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (err || Math.floor(res.statusCode/100)!==2) {
 | 
					    if (err || Math.floor(res.statusCode/100)!==2) {
 | 
				
			||||||
      log('Certificate request failed with error ', err);
 | 
					      log('Certificate request failed with error ', err);
 | 
				
			||||||
@ -180,21 +180,21 @@ function getCert(options, cb) {
 | 
				
			|||||||
    log('Requesting certificate: done');
 | 
					    log('Requesting certificate: done');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    state.certificate=body;
 | 
					    state.certificate=body;
 | 
				
			||||||
    certURL=res.headers.location;
 | 
					    certUrl=res.headers.location;
 | 
				
			||||||
    request.get({
 | 
					    request.get({
 | 
				
			||||||
      url:certURL,
 | 
					      url:certUrl,
 | 
				
			||||||
      encoding:null
 | 
					      encoding:null
 | 
				
			||||||
    }, function(err, res, body) {
 | 
					    }, function(err, res, body) {
 | 
				
			||||||
      if (err) {
 | 
					      if (err) {
 | 
				
			||||||
        return handleErr(err, 'Failed to fetch cert from '+certURL);
 | 
					        return handleErr(err, 'Failed to fetch cert from '+certUrl);
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      if (res.statusCode!==200) {
 | 
					      if (res.statusCode!==200) {
 | 
				
			||||||
        return handleErr(err, 'Failed to fetch cert from '+certURL, res.body.toString());
 | 
					        return handleErr(err, 'Failed to fetch cert from '+certUrl, res.body.toString());
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      if (body.toString()!==state.certificate.toString()) {
 | 
					      if (body.toString()!==state.certificate.toString()) {
 | 
				
			||||||
        handleErr(null, 'Cert at '+certURL+' did not match returned cert');
 | 
					        handleErr(null, 'Cert at '+certUrl+' did not match returned cert');
 | 
				
			||||||
      } else {
 | 
					      } else {
 | 
				
			||||||
        log('Successfully verified cert at '+certURL);
 | 
					        log('Successfully verified cert at '+certUrl);
 | 
				
			||||||
        log('Requesting issuer certificate...');
 | 
					        log('Requesting issuer certificate...');
 | 
				
			||||||
        request.get({
 | 
					        request.get({
 | 
				
			||||||
          url:links.up,
 | 
					          url:links.up,
 | 
				
			||||||
 | 
				
			|||||||
@ -62,19 +62,19 @@ function registerNewAccount(options, cb) {
 | 
				
			|||||||
    state.termsRequired=('terms-of-service' in links);
 | 
					    state.termsRequired=('terms-of-service' in links);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (state.termsRequired) {
 | 
					    if (state.termsRequired) {
 | 
				
			||||||
      state.termsURL=links['terms-of-service'];
 | 
					      state.termsUrl=links['terms-of-service'];
 | 
				
			||||||
      options.agreeToTerms(state.termsURL, function (err, agree) {
 | 
					      options.agreeToTerms(state.termsUrl, function (err, agree) {
 | 
				
			||||||
        if (err) {
 | 
					        if (err) {
 | 
				
			||||||
          return handleErr(err);
 | 
					          return handleErr(err);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        if (!agree) {
 | 
					        if (!agree) {
 | 
				
			||||||
          return handleErr(new Error("You must agree to the terms of use at '" + state.termsURL + "'"));
 | 
					          return handleErr(new Error("You must agree to the terms of use at '" + state.termsUrl + "'"));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        state.agreeTerms = agree;
 | 
					        state.agreeTerms = agree;
 | 
				
			||||||
        state.termsURL=links['terms-of-service'];
 | 
					        state.termsUrl=links['terms-of-service'];
 | 
				
			||||||
        log(state.termsURL);
 | 
					        log(state.termsUrl);
 | 
				
			||||||
        request.get(state.termsURL, getAgreement);
 | 
					        request.get(state.termsUrl, getAgreement);
 | 
				
			||||||
      });
 | 
					      });
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
      cb();
 | 
					      cb();
 | 
				
			||||||
@ -85,20 +85,20 @@ function registerNewAccount(options, cb) {
 | 
				
			|||||||
    if (err) {
 | 
					    if (err) {
 | 
				
			||||||
      return handleErr(err, 'Couldn\'t get agreement');
 | 
					      return handleErr(err, 'Couldn\'t get agreement');
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    log('The CA requires your agreement to terms:\n'+state.termsURL);
 | 
					    log('The CA requires your agreement to terms:\n'+state.termsUrl);
 | 
				
			||||||
    sendAgreement();
 | 
					    sendAgreement();
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  function sendAgreement() {
 | 
					  function sendAgreement() {
 | 
				
			||||||
    if (state.termsRequired && !state.agreeTerms) {
 | 
					    if (state.termsRequired && !state.agreeTerms) {
 | 
				
			||||||
      return handleErr(null, 'The CA requires your agreement to terms: '+state.termsURL);
 | 
					      return handleErr(null, 'The CA requires your agreement to terms: '+state.termsUrl);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    log('Posting agreement to: '+state.registrationUrl);
 | 
					    log('Posting agreement to: '+state.registrationUrl);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    state.acme.post(state.registrationUrl, {
 | 
					    state.acme.post(state.registrationUrl, {
 | 
				
			||||||
      resource:'reg',
 | 
					      resource:'reg',
 | 
				
			||||||
      agreement:state.termsURL
 | 
					      agreement:state.termsUrl
 | 
				
			||||||
    }, function(err, res, body) {
 | 
					    }, function(err, res, body) {
 | 
				
			||||||
      if (err || Math.floor(res.statusCode/100)!==2) {
 | 
					      if (err || Math.floor(res.statusCode/100)!==2) {
 | 
				
			||||||
        return handleErr(err, 'Couldn\'t POST agreement back to server', body);
 | 
					        return handleErr(err, 'Couldn\'t POST agreement back to server', body);
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user