How can I receive the header and footer in getting the public key from KMS?

0

I'm retrieving a public key from KMS using the javascript SDK. The result has the property PublicKey which is of type Uint8Array. I'm verifying a token using the jsonwebtoken library. I'm not verifying the token with the KMS SDK because I'm implementing a microservice architecture and the signing and verification happen in different services so my verification code does not have access to the Signature returned by the sign method on the KMS client.

Back to the KMS client, the result has the property PublicKey which is of type Uint8Array. This can be converted to a string with the following code Buffer.from(result.PublicKey).toString('base64'). This does not follow a verifiable format however.

I'm expecting to see the string formatted as '-----BEGIN RSA PUBLIC KEY-----foo foo foo' with the appropriate header and footer. When I parse the public key, however, I'm only receiving the body and not the header and footer of the public key.

How can I receive the header and footer in getting the public key from KMS?

Edited by: kylewright on Sep 29, 2021 4:52 PM

質問済み 3年前455ビュー
1回答
0

I've found a workaround for this problem.

const publicKey = '-----BEGIN PUBLIC KEY-----\n' _ kmsPublicKey.replace(/(.{64})/g, '$&' _ '\n' ) + '\n-----END PUBLIC KEY-----';

Yes, it isn't very pretty, but it gets the job done.

KMS team, can there be a option to retrieve the public key with the appropriate header and footer on the getPublicKey method?

回答済み 3年前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ