From 5aeada46c2066fb1923bf24ce35e4d13f61324ab Mon Sep 17 00:00:00 2001 From: Steve Astels Date: Mon, 24 Feb 2020 11:02:24 -0500 Subject: [PATCH] add newline if needed (#1523) Co-authored-by: dhcdn <51758091+davidheerema@users.noreply.github.com> Co-authored-by: DianeLiu2019 <51336707+DianeLiu2019@users.noreply.github.com> --- f2/src/utils/encryptedEmail.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/f2/src/utils/encryptedEmail.js b/f2/src/utils/encryptedEmail.js index a94103250..fd360b1da 100644 --- a/f2/src/utils/encryptedEmail.js +++ b/f2/src/utils/encryptedEmail.js @@ -32,10 +32,11 @@ const getCert = uid => { ) { res.on('searchEntry', function(entry) { console.log(`Encrypted Mail: Found LDAP entry for ${uid}`) - const cert = + let cert = '-----BEGIN CERTIFICATE-----\r\n' + - entry.object['userCertificate;binary'].replace(/(.{64})/g, '$1\r\n') + - '-----END CERTIFICATE-----' + entry.object['userCertificate;binary'].replace(/(.{64})/g, '$1\r\n') + if (!cert.endsWith('\n')) cert += '\n' + cert += '-----END CERTIFICATE-----' fs.writeFile(certFileName(uid), cert, function(err) { if (err) throw err else console.log(`Encrypted Mail: Certificate for ${uid} Saved!`)