|
1 | 1 | const forge = require("node-forge"); |
2 | 2 | const fs = require("fs"); |
3 | | -const path = require("path") |
4 | 3 | const c = require("../utils/constants"); |
5 | 4 |
|
6 | 5 | /** |
@@ -208,17 +207,17 @@ module.exports.getPrivateKey = function (config) { |
208 | 207 | ); |
209 | 208 | } |
210 | 209 |
|
211 | | - return getUnencryptedPrivateKey(config.keyStore) |
| 210 | + return getUnencryptedPrivateKey(config.keyStore); |
212 | 211 | } |
213 | 212 |
|
214 | 213 | return null; |
215 | 214 | }; |
216 | 215 |
|
217 | 216 | function getUnencryptedPrivateKey(filePath) { |
218 | | - const fileContent = fs.readFileSync(filePath) |
| 217 | + const fileContent = fs.readFileSync(filePath); |
219 | 218 |
|
220 | 219 | if (!fileContent || fileContent.length < 1) { |
221 | | - throw new Error("private key file content is empty") |
| 220 | + throw new Error("private key file content is empty"); |
222 | 221 | } |
223 | 222 |
|
224 | 223 | // key is PEM |
@@ -333,6 +332,8 @@ module.exports.checkConfigFieldsArePopulated = function(config, propertiesBasic, |
333 | 332 | return config[elem] !== null && typeof config[elem] !== "undefined"; |
334 | 333 | }); |
335 | 334 | }; |
| 335 | + |
| 336 | + // eslint-disable-next-line eqeqeq |
336 | 337 | if (typeof config !== "object" || config == null) { |
337 | 338 | throw Error("Config not valid: config should be an object."); |
338 | 339 | } |
@@ -445,11 +446,11 @@ module.exports.readPublicCertificateContent = function (config) { |
445 | 446 | throw new Error("Public certificate content is not valid"); |
446 | 447 | } |
447 | 448 | return forge.pki.certificateFromPem(config.encryptionCertificate); |
448 | | -} |
| 449 | +}; |
449 | 450 |
|
450 | 451 | module.exports.getPrivateKeyFromContent = function(config) { |
451 | 452 | if (config.privateKey) { |
452 | 453 | return forge.pki.privateKeyFromPem(config.privateKey); |
453 | 454 | } |
454 | 455 | return null; |
455 | | -} |
| 456 | +}; |
0 commit comments