minor cleanup

This commit is contained in:
AJ ONeal 2016-08-09 15:58:11 -04:00
parent 60e4ed8f7b
commit 17df564f69
2 changed files with 8 additions and 25 deletions

View File

@ -1,17 +0,0 @@
/*!
* letiny
* Copyright(c) 2015 Anatol Sommer <anatol@anatol.at>
* Some code used from https://github.com/letsencrypt/boulder/tree/master/test/js
* MPL 2.0
*/
'use strict';
exports.Acme = require('./acme-client');
exports.registerNewAccount = require('./register-new-account');
exports.getCertificate = require('./get-certificate');
exports.getCert=function (options, cb) {
exports.registerNewAccount(options, function () {
exports.getCertificate(options, cb);
});
};

View File

@ -17,8 +17,14 @@ function _toStandardBase64(str) {
return b64; return b64;
} }
function certBufferToPem(cert) {
cert = _toStandardBase64(cert.toString('base64'));
cert = cert.match(/.{1,64}/g).join('\r\n');
return '-----BEGIN CERTIFICATE-----\r\n'+cert+'\r\n-----END CERTIFICATE-----\r\n';
}
module.exports.create = function (deps) { module.exports.create = function (deps) {
var request=deps.request; var request = deps.request;
var Acme = deps.Acme; var Acme = deps.Acme;
var RSA = deps.RSA; var RSA = deps.RSA;
@ -321,7 +327,7 @@ module.exports.create = function (deps) {
return handleErr(err, 'Failed to fetch issuer certificate'); return handleErr(err, 'Failed to fetch issuer certificate');
} }
state.chainPem=certBufferToPem(body); state.chainPem = certBufferToPem(body);
log('Requesting issuer certificate: done'); log('Requesting issuer certificate: done');
done(); done();
}); });
@ -402,11 +408,5 @@ module.exports.create = function (deps) {
nextDomain(); nextDomain();
} }
function certBufferToPem(cert) {
cert=_toStandardBase64(cert.toString('base64'));
cert=cert.match(/.{1,64}/g).join('\r\n');
return '-----BEGIN CERTIFICATE-----\r\n'+cert+'\r\n-----END CERTIFICATE-----\r\n';
}
return getCert; return getCert;
}; };