save pems by name
This commit is contained in:
parent
c2dd6d3d47
commit
1b4da6d9a0
|
@ -34,10 +34,13 @@ Certificate.prototype.quasiPEM = function quasiPEM() {
|
||||||
converted.writeUInt8(parseInt(bytes.shift(), 8), offset++);
|
converted.writeUInt8(parseInt(bytes.shift(), 8), offset++);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ' // ' + this.name + '\n' +
|
return {
|
||||||
' "-----BEGIN CERTIFICATE-----\\n" +\n' +
|
name: this.name
|
||||||
converted.toString('base64').replace(/(.{1,76})/g, ' "$1\\n" +\n') +
|
, value: ' // ' + this.name + '\n'
|
||||||
' "-----END CERTIFICATE-----\\n"';
|
+ ' "-----BEGIN CERTIFICATE-----\\n" +\n'
|
||||||
|
+ converted.toString('base64').replace(/(.{1,76})/g, ' "$1\\n" +\n')
|
||||||
|
+ ' "-----END CERTIFICATE-----\\n"'
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
function parseBody(current, lines) {
|
function parseBody(current, lines) {
|
||||||
|
@ -113,8 +116,12 @@ function parseCertData(lines) {
|
||||||
|
|
||||||
function dumpCerts(certs, filename, pemsDir) {
|
function dumpCerts(certs, filename, pemsDir) {
|
||||||
certs.forEach(function (cert, i) {
|
certs.forEach(function (cert, i) {
|
||||||
var pemsFile = path.join(pemsDir, 'ca-' + i + '.pem');
|
var pem = cert.quasiPEM()
|
||||||
fs.writeFileSync(pemsFile, cert.quasiPEM());
|
, pemName = pem.name.toLowerCase().replace(/\W/, '-').replace(/-+/, '-')
|
||||||
|
, pemsFile = path.join(pemsDir, pemName + '.pem')
|
||||||
|
;
|
||||||
|
|
||||||
|
fs.writeFileSync(pemsFile, pem.value);
|
||||||
});
|
});
|
||||||
console.info("Wrote " + certs.length + " certificates in '"
|
console.info("Wrote " + certs.length + " certificates in '"
|
||||||
+ path.join(__dirname, 'pems/').replace(/'/g, "\\'") + "'.");
|
+ path.join(__dirname, 'pems/').replace(/'/g, "\\'") + "'.");
|
||||||
|
@ -123,7 +130,7 @@ function dumpCerts(certs, filename, pemsDir) {
|
||||||
filename
|
filename
|
||||||
, HEADER
|
, HEADER
|
||||||
+ 'var cas = module.exports = [\n'
|
+ 'var cas = module.exports = [\n'
|
||||||
+ certs.map(function (cert) { return cert.quasiPEM(); }).join(',\n\n')
|
+ certs.map(function (cert) { return cert.quasiPEM().value; }).join(',\n\n')
|
||||||
+ '\n];\n'
|
+ '\n];\n'
|
||||||
+ "module.exports.rootCas = cas;\n"
|
+ "module.exports.rootCas = cas;\n"
|
||||||
+ "module.exports.inject = function () {\n"
|
+ "module.exports.inject = function () {\n"
|
||||||
|
|
Loading…
Reference in New Issue