fix #11 output pems with CRLF, end in CRLF
This commit is contained in:
parent
b980fde859
commit
572621086e
|
@ -298,6 +298,11 @@ module.exports.create = function (deps) {
|
|||
}
|
||||
|
||||
log('Successfully verified cert at '+certUrl);
|
||||
downloadIssuerCert(links);
|
||||
});
|
||||
}
|
||||
|
||||
function downloadIssuerCert(links) {
|
||||
log('Requesting issuer certificate...');
|
||||
request({
|
||||
method: 'GET'
|
||||
|
@ -316,35 +321,22 @@ module.exports.create = function (deps) {
|
|||
return handleErr(err, 'Failed to fetch issuer certificate');
|
||||
}
|
||||
|
||||
state.caCertPem=certBufferToPem(body);
|
||||
state.chainPem=certBufferToPem(body);
|
||||
log('Requesting issuer certificate: done');
|
||||
done();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function done() {
|
||||
var certPem;
|
||||
var privkeyPem;
|
||||
var privkeyPem = RSA.exportPrivatePem(state.certKeypair);
|
||||
|
||||
try {
|
||||
certPem = certBufferToPem(state.certificate);
|
||||
} catch(e) {
|
||||
console.error(e.stack);
|
||||
//cb(new Error("Could not write output files. Please check permissions!"));
|
||||
handleErr(e, 'Could not write output files. Please check permissions!');
|
||||
return;
|
||||
}
|
||||
|
||||
privkeyPem = RSA.exportPrivatePem(state.certKeypair);
|
||||
cb(null, {
|
||||
cert: certPem
|
||||
// TODO privkey isn't necessary
|
||||
cert: certBufferToPem(state.certificate)
|
||||
, privkey: privkeyPem
|
||||
, chain: state.caCertPem
|
||||
// TODO nix key, ca
|
||||
, chain: state.chainPem
|
||||
// TODO nix backwards compat
|
||||
, key: privkeyPem
|
||||
, ca: state.caCertPem
|
||||
, ca: state.chainPem
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -412,8 +404,8 @@ module.exports.create = function (deps) {
|
|||
|
||||
function certBufferToPem(cert) {
|
||||
cert=_toStandardBase64(cert.toString('base64'));
|
||||
cert=cert.match(/.{1,64}/g).join('\n');
|
||||
return '-----BEGIN CERTIFICATE-----\n'+cert+'\n-----END CERTIFICATE-----';
|
||||
cert=cert.match(/.{1,64}/g).join('\r\n');
|
||||
return '-----BEGIN CERTIFICATE-----\r\n'+cert+'\r\n-----END CERTIFICATE-----\r\n';
|
||||
}
|
||||
|
||||
return getCert;
|
||||
|
|
Loading…
Reference in New Issue