Skip to content

Commit

Permalink
GCP KMS bugfix (#710)
Browse files Browse the repository at this point in the history
* replace String.raw`\n` with `\n` in gcp private key

* refactor

* remove redundant sanitisation
  • Loading branch information
d4mr authored Oct 7, 2024
1 parent 1729051 commit cd02aa3
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/server/utils/wallets/getGcpKmsAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,18 @@ export async function getGcpKmsAccount(
): Promise<GcpKmsAccount> {
const { name: unprocessedName, clientOptions, client } = options;

if (clientOptions?.credentials) {
if (
"private_key" in clientOptions.credentials &&
clientOptions.credentials.private_key
) {
// https://stackoverflow.com/questions/74131595/error-error1e08010cdecoder-routinesunsupported-with-google-auth-library
// new keys are stored correctly with newlines, but older keys need this sanitization for backwards compatibility
clientOptions.credentials.private_key =
clientOptions.credentials.private_key.split(String.raw`\n`).join("\n");
}
}

// we had a bug previously where we previously called it "cryptoKeyVersion" instead of "cryptoKeyVersions"
// if we detect that, we'll fix it here
// TODO: remove this as a breaking change
Expand Down

0 comments on commit cd02aa3

Please sign in to comment.