|
|
@ -34,6 +34,8 @@ function getRootCerts(callback) { |
|
|
|
+ '"' + key + '":\n'; |
|
|
|
}); |
|
|
|
body += '' |
|
|
|
+ '\n' |
|
|
|
+ 'certs.__proto__ = null;\n' |
|
|
|
+ '\n' |
|
|
|
+ '// Use hash table for efficiency:\n' |
|
|
|
+ 'var trusted = Object.keys(certs).reduce(function(trusted, key) {\n' |
|
|
@ -43,18 +45,21 @@ function getRootCerts(callback) { |
|
|
|
+ ' pem = pem.replace(/\\s+/g, "");\n' |
|
|
|
+ ' trusted[pem] = key;\n' |
|
|
|
+ ' return trusted;\n' |
|
|
|
+ '}, {});\n' |
|
|
|
+ '}, { __proto__: null });\n' |
|
|
|
+ '\n' |
|
|
|
+ 'function getTrusted(pem) {\n' |
|
|
|
+ ' pem = pem + "";\n' |
|
|
|
+ ' pem = pem.replace(/-----BEGIN CERTIFICATE-----/g, "");\n' |
|
|
|
+ ' pem = pem.replace(/-----END CERTIFICATE-----/g, "");\n' |
|
|
|
+ ' pem = pem.replace(/\\s+/g, "");\n' |
|
|
|
+ ' if (pem === "__proto__") return;\n' |
|
|
|
+ ' return certs[pem];\n' |
|
|
|
+ '}\n' |
|
|
|
+ '\n' |
|
|
|
+ 'function getCert(name) {\n' |
|
|
|
+ ' return trusted[name.replace(/^\s+|\s+$/g, "")];\n' |
|
|
|
+ ' name = name.replace(/^\s+|\s+$/g, "");\n' |
|
|
|
+ ' if (name === "__proto__") return;\n' |
|
|
|
+ ' return trusted[name];\n' |
|
|
|
+ '}\n' |
|
|
|
+ '\n' |
|
|
|
+ 'exports.certs = certs;\n' |
|
|
|