17 lines
421 B
JavaScript
17 lines
421 B
JavaScript
|
'use strict';
|
||
|
|
||
|
var fs = require('fs');
|
||
|
var path = require('path');
|
||
|
|
||
|
function convert(name) {
|
||
|
var ext = path.extname(name);
|
||
|
var csr = fs.readFileSync(name, 'ascii').split(/\n/).filter(function (line) {
|
||
|
return !/---/.test(line);
|
||
|
}).join('');
|
||
|
console.log(csr);
|
||
|
var der = Buffer.from(csr, 'base64');
|
||
|
fs.writeFileSync(name.replace(new RegExp('\\' + ext + '$'), '') + '.der', der);
|
||
|
}
|
||
|
|
||
|
convert(process.argv[2]);
|