-
Notifications
You must be signed in to change notification settings - Fork 64
Expand file tree
/
Copy pathutils.js
More file actions
29 lines (24 loc) · 767 Bytes
/
utils.js
File metadata and controls
29 lines (24 loc) · 767 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
var templates = {
'encrypted-key': require('./templates/encrypted-key.tpl.xml.js'),
'keyinfo': require('./templates/keyinfo.tpl.xml.js'),
};
function renderTemplate(file, data) {
return templates[file](data);
}
function pemToCert(pem) {
var cert = /-----BEGIN CERTIFICATE-----([^-]*)-----END CERTIFICATE-----/g.exec(pem);
if (cert.length > 0) {
return cert[1].replace(/[\n|\r\n]/g, '');
}
return null;
};
function warnInsecureAlgorithm(algorithm, enabled = true) {
if (enabled) {
console.warn(algorithm + " is no longer recommended due to security reasons. Please deprecate its use as soon as possible.")
}
}
module.exports = {
renderTemplate: renderTemplate,
pemToCert: pemToCert,
warnInsecureAlgorithm: warnInsecureAlgorithm
};