Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion apps/web/src/records.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,10 @@ let jwtKey = null;
function privateKey() {
const pem = process.env.CLIENT_JWT_PRIVATE_KEY;
if (!pem) return null;
if (!jwtKey || jwtKey.pem !== pem) jwtKey = { pem, key: createPrivateKey(pem.replace(/\\n/g, '\n')) };
// The vault and the env file each add a level of escaping, so a PEM can arrive
// with literal \n, \\n, or real newlines left with a stray backslash. Base64
// never contains a backslash, so collapsing every form to a newline is safe.
if (!jwtKey || jwtKey.pem !== pem) jwtKey = { pem, key: createPrivateKey(pem.replace(/\\+(\n|n)/g, '\n')) };
return jwtKey.key;
}

Expand Down
Loading