Skip to content

Commit

Permalink
fix: Correct private key formatting for consistent handling (#438)
Browse files Browse the repository at this point in the history
  • Loading branch information
nadeesha authored Dec 31, 2024
1 parent c896645 commit 2cc8248
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions control-plane/src/modules/integrations/valtown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,14 @@ export const signedHeaders = ({
return {};
}

// Handle both raw and PEM-formatted private keys
const keyToUse = privateKey.includes("PRIVATE KEY")
? privateKey
: `-----BEGIN PRIVATE KEY-----\n${privateKey}\n-----END PRIVATE KEY-----`;
const keyToUse = [
"-----BEGIN PRIVATE KEY-----",
...(privateKey.match(/.{1,64}/g) || []),
"-----END PRIVATE KEY-----",
].join("\n");

//TODO: Remove this
console.log("Key to use:", keyToUse);

const sign = createSign("SHA256");
sign.update(`${timestamp}${method}${path}${body}`);
Expand Down

0 comments on commit 2cc8248

Please sign in to comment.