From 090e9a17c33e99b9073206f6a240d6f69464db2c Mon Sep 17 00:00:00 2001 From: Roberto Dip Date: Fri, 27 Jan 2023 15:54:40 -0300 Subject: [PATCH] doubly encode the CSR in base64 (#9532) When the file is provided as an attachment to the Sails helper, it gets decoded, since we need for the signed CSR to be delivered in base64 format, we doubly encode the contents before sending the email. --- website/api/controllers/deliver-apple-csr.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/website/api/controllers/deliver-apple-csr.js b/website/api/controllers/deliver-apple-csr.js index 834b13dff8..238d8a97af 100644 --- a/website/api/controllers/deliver-apple-csr.js +++ b/website/api/controllers/deliver-apple-csr.js @@ -139,7 +139,11 @@ module.exports = { template: 'email-signed-csr-for-apns', templateData: {}, attachments: [{ - contentBytes: generateCertificateResult.request, + // When the file is provided as an attachment to the Sails helper, it + // gets decoded, since we need for the signed CSR to be delivered in + // base64 format, we doubly encode the contents before sending the + // email. + contentBytes: Buffer.from(generateCertificateResult.request).toString('base64'), name: 'apple-apns-request.txt', type: 'text/plain', }],