Skip to content

Commit bd4d269

Browse files
logging file name
1 parent ccf235d commit bd4d269

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/authentication/util/Utility.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,8 @@ exports.readPrivateKeyFromP12 = function(filePath, password, logger) {
212212

213213
return rsaPrivateKey;
214214
} catch (error) {
215-
logger.error(`Error reading private key from P12 file: ${error.message}`);
216-
ApiException.AuthException(error.message + ". " + Constants.INCORRECT_KEY_PASS);
215+
logger.error(`Error reading private key from P12 file: ${filePath}: ${error.message}`);
216+
ApiException.AuthException(`Error reading private key from P12 file: ${filePath}: ${error.message}. ${Constants.INCORRECT_KEY_PASS}`);
217217
}
218218
};
219219

@@ -244,8 +244,8 @@ exports.readPrivateKeyFromPemFile = function(filePath, password, logger) {
244244
logger.debug(`PEM file contains ${isEncrypted ? 'an encrypted' : 'an unencrypted'} private key`);
245245

246246
if (isEncrypted && (!password || password.trim() === '')) {
247-
logger.error(`Password is required for encrypted private key`);
248-
ApiException.AuthException("Password is required for encrypted private key");
247+
logger.error(`Password is required for encrypted private key: ${filePath}`);
248+
ApiException.AuthException(`Password is required for encrypted private key: ${filePath}`);
249249
}
250250

251251
try {
@@ -261,19 +261,19 @@ exports.readPrivateKeyFromPemFile = function(filePath, password, logger) {
261261
}
262262

263263
if (!privateKey) {
264-
logger.error(`Failed to parse private key from PEM file`);
265-
ApiException.AuthException("Failed to parse private key from PEM file");
264+
logger.error(`Failed to parse private key from PEM file: ${filePath}`);
265+
ApiException.AuthException(`Failed to parse private key from PEM file: ${filePath}`);
266266
}
267267

268268
logger.debug(`Successfully extracted private key from PEM file`);
269269

270270
return forge.pki.privateKeyToPem(privateKey);
271271
} catch (error) {
272-
logger.error(`Error parsing private key: ${error.message}`);
273-
ApiException.AuthException("Error parsing private key: " + error.message);
272+
logger.error(`Error parsing private key from ${filePath}: ${error.message}`);
273+
ApiException.AuthException(`Error parsing private key from ${filePath}: ${error.message}`);
274274
}
275275
} catch (error) {
276-
logger.error(`Error loading private key from PEM file: ${error.message}`);
277-
ApiException.AuthException("Error loading private key from PEM file: " + error.message);
276+
logger.error(`Error loading private key from PEM file: ${filePath}: ${error.message}`);
277+
ApiException.AuthException(`Error loading private key from PEM file: ${filePath}: ${error.message}`);
278278
}
279279
};

0 commit comments

Comments
 (0)