mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-09-22 13:39:35 +00:00
fix: public key encoding as DER
This commit is contained in:
@@ -302,7 +302,9 @@ export const cmekServiceFactory = ({ kmsService, kmsDAL, permissionService, proj
|
||||
|
||||
const publicKey = await kmsService.getPublicKey({ kmsId: keyId });
|
||||
|
||||
return { publicKey, projectId: key.projectId };
|
||||
const base64EncodedPublicKey = publicKey.toString("base64");
|
||||
|
||||
return { publicKey: base64EncodedPublicKey, projectId: key.projectId };
|
||||
};
|
||||
|
||||
const cmekSign = async ({ keyId, data, signingAlgorithm }: TCmekSignDTO, actor: OrgServiceActor) => {
|
||||
|
||||
@@ -454,13 +454,16 @@ export const kmsServiceFactory = ({
|
||||
|
||||
const publicKeyBuffer = signingService(encryptionAlgorithm).getPublicKeyFromPrivateKey(kmsKey);
|
||||
|
||||
return crypto
|
||||
.createPublicKey({
|
||||
key: publicKeyBuffer,
|
||||
format: "pem",
|
||||
type: "spki"
|
||||
})
|
||||
.export({ type: "spki", format: "pem" }) as string; // format 'pem' makes it a string
|
||||
return (
|
||||
crypto
|
||||
.createPublicKey({
|
||||
key: publicKeyBuffer,
|
||||
format: "pem",
|
||||
type: "spki"
|
||||
})
|
||||
// We return as a DER encoded X.509 certificate (https://datatracker.ietf.org/doc/html/rfc5280)
|
||||
.export({ type: "spki", format: "der" })
|
||||
);
|
||||
};
|
||||
|
||||
const signWithKmsKey = async ({ kmsId }: Pick<TSignWithKmsDTO, "kmsId">) => {
|
||||
|
||||
Reference in New Issue
Block a user