From 3ef528ae1b109963e531bfd6ade97a3301e221df Mon Sep 17 00:00:00 2001 From: Mike Flynn Date: Sat, 18 Jun 2016 16:41:26 -0700 Subject: [PATCH] Added check for the correct content type in addition to the response status code. --- ca-store-generator.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ca-store-generator.js b/ca-store-generator.js index fad899e..da803d2 100644 --- a/ca-store-generator.js +++ b/ca-store-generator.js @@ -200,7 +200,7 @@ function run(filename) { if (!fs.existsSync(outputPemsDir)) { fs.mkdirSync(outputPemsDir); - } + } console.info("Loading latest certificates from " + CERTDB_URL); request.get(CERTDB_URL, function (error, response, body) { @@ -217,6 +217,12 @@ function run(filename) { return; } + if (response.headers['content-type'] !== 'text/plain') { + console.error("Fetching failed with incorrect content type %s", response.headers['content-type']); + reject({ code: 2, error: "Fetching failed with incorrect content type " + response.headers['content-type'] }); + return; + } + var lines = body.split("\n") , certs = parseCertData(lines) , pemsFile = path.join(outputPemsDir, 'mozilla-certdata.txt')