diff --git a/lib/acme-client.js b/lib/acme-client.js index b261d41..6e64617 100644 --- a/lib/acme-client.js +++ b/lib/acme-client.js @@ -69,7 +69,7 @@ Acme.prototype.post=function(url, body, cb) { var parsed; if (err) { - console.error(err); + console.error(err.stack); return cb(err); } if (res) { diff --git a/lib/get-certificate.js b/lib/get-certificate.js index ae4e185..fad173d 100644 --- a/lib/get-certificate.js +++ b/lib/get-certificate.js @@ -60,7 +60,7 @@ function getCert(options, cb) { function getChallenges(domain) { state.domain=domain; - state.acme.post(state.newAuthorizationURL, { + state.acme.post(state.newAuthorizationUrl, { resource:'new-authz', identifier:{ type:'dns', @@ -72,8 +72,12 @@ function getCert(options, cb) { function getReadyToValidate(err, res, body) { var links, authz, httpChallenges, challenge, thumbprint, keyAuthorization, challengePath; - if (err || Math.floor(res.statusCode/100)!==2) { - return handleErr(err, 'Authorization request failed ('+res.statusCode+')'); + if (err) { + return handleErr(err); + } + + if (Math.floor(res.statusCode/100)!==2) { + return handleErr(null, 'Authorization request failed ('+res.statusCode+')'); } links=Acme.parseLink(res.headers.link); diff --git a/lib/register-new-account.js b/lib/register-new-account.js index e35792d..79276a0 100644 --- a/lib/register-new-account.js +++ b/lib/register-new-account.js @@ -56,8 +56,9 @@ function registerNewAccount(options, cb) { return handleErr(err, 'Server didn\'t provide information to proceed (1)'); } - state.registrationURL=res.headers.location; - state.newAuthorizationURL=links.next; + state.registrationUrl=res.headers.location; + // TODO should we pass this along? + //state.newAuthorizationUrl=links.next; state.termsRequired=('terms-of-service' in links); if (state.termsRequired) { @@ -93,9 +94,9 @@ function registerNewAccount(options, cb) { 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', agreement:state.termsURL }, function(err, res, body) {