small code improvements
This commit is contained in:
parent
9707b4dac8
commit
d1c2dd4dcf
|
@ -1,3 +1,8 @@
|
||||||
|
0.0.4-beta / 2015-12-13
|
||||||
|
=======================
|
||||||
|
|
||||||
|
* Small code improvements
|
||||||
|
|
||||||
0.0.3-beta / 2015-12-13
|
0.0.3-beta / 2015-12-13
|
||||||
=======================
|
=======================
|
||||||
|
|
||||||
|
|
|
@ -112,14 +112,14 @@ function getCert(options, cb) {
|
||||||
options.newReg=options.newReg || 'https://acme-v01.api.letsencrypt.org/acme/new-reg';
|
options.newReg=options.newReg || 'https://acme-v01.api.letsencrypt.org/acme/new-reg';
|
||||||
|
|
||||||
if (!options.email) {
|
if (!options.email) {
|
||||||
return cb(new Error('No "email" option given!'));
|
return cb(new Error('No "email" option specified!'));
|
||||||
}
|
}
|
||||||
if (typeof options.domains==='string') {
|
if (typeof options.domains==='string') {
|
||||||
state.domains=options.domains.split(/[, ]+/);
|
state.domains=options.domains.split(/[, ]+/);
|
||||||
} else if (options.domains && options.domains instanceof Array) {
|
} else if (options.domains && options.domains instanceof Array) {
|
||||||
state.domains=options.domains.slice();
|
state.domains=options.domains.slice();
|
||||||
} else {
|
} else {
|
||||||
return cb(new Error('No valid "domains" option given!'));
|
return cb(new Error('No valid "domains" option specified!'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((_DEBUG=options.debug)) {
|
if ((_DEBUG=options.debug)) {
|
||||||
|
@ -235,7 +235,7 @@ function getCert(options, cb) {
|
||||||
var links, authz, httpChallenges, challenge, thumbprint, keyAuthorization, challengePath;
|
var links, authz, httpChallenges, challenge, thumbprint, keyAuthorization, challengePath;
|
||||||
|
|
||||||
if (err || Math.floor(res.statusCode/100)!==2) {
|
if (err || Math.floor(res.statusCode/100)!==2) {
|
||||||
return handleErr(err, 'Authorization request failed with code '+res.statusCode);
|
return handleErr(err, 'Authorization request failed ('+res.statusCode+')');
|
||||||
}
|
}
|
||||||
|
|
||||||
links=parseLink(res.headers['link']);
|
links=parseLink(res.headers['link']);
|
||||||
|
@ -344,7 +344,7 @@ function getCert(options, cb) {
|
||||||
|
|
||||||
links=parseLink(res.headers['link']);
|
links=parseLink(res.headers['link']);
|
||||||
if (!links || !('up' in links)) {
|
if (!links || !('up' in links)) {
|
||||||
return handleErr(err, 'Failed to fetch CA certificate');
|
return handleErr(err, 'Failed to fetch issuer certificate');
|
||||||
}
|
}
|
||||||
|
|
||||||
log('Requesting certificate: done');
|
log('Requesting certificate: done');
|
||||||
|
@ -365,16 +365,16 @@ function getCert(options, cb) {
|
||||||
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 CA certificate...');
|
log('Requesting issuer certificate...');
|
||||||
request.get({
|
request.get({
|
||||||
url:links['up'],
|
url:links['up'],
|
||||||
encoding:null
|
encoding:null
|
||||||
}, function(err, res, body) {
|
}, function(err, res, body) {
|
||||||
if (err || res.statusCode!==200) {
|
if (err || res.statusCode!==200) {
|
||||||
return handleErr(err, 'Failed to fetch CA certificate');
|
return handleErr(err, 'Failed to fetch issuer certificate');
|
||||||
}
|
}
|
||||||
state.caCert=certBufferToPEM(body);
|
state.caCert=certBufferToPEM(body);
|
||||||
log('Requesting CA certificate: done');
|
log('Requesting issuer certificate: done');
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -410,7 +410,7 @@ function getCert(options, cb) {
|
||||||
}
|
}
|
||||||
cb(null, cert, state.certPrivateKeyPEM, state.caCert);
|
cb(null, cert, state.certPrivateKeyPEM, state.caCert);
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
handleErr(err, 'Could not write output files');
|
handleErr(err, 'Could not write output files. Please check permissions!');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,13 @@
|
||||||
{
|
{
|
||||||
"name": "letiny",
|
"name": "letiny",
|
||||||
"version": "0.0.3-beta",
|
"version": "0.0.4-beta",
|
||||||
"description": "Tiny ACME client library and CLI",
|
"description": "Tiny ACME client library and CLI",
|
||||||
"author": "Anatol Sommer <anatol@anatol.at>",
|
"author": "Anatol Sommer <anatol@anatol.at>",
|
||||||
"license": "MPL",
|
"license": "MPL",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/anatolsommer/letiny.git"
|
||||||
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"tiny",
|
"tiny",
|
||||||
"acme",
|
"acme",
|
||||||
|
|
Loading…
Reference in New Issue