mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-07 16:27:40 +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 });
|
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) => {
|
const cmekSign = async ({ keyId, data, signingAlgorithm }: TCmekSignDTO, actor: OrgServiceActor) => {
|
||||||
|
|||||||
@@ -454,13 +454,16 @@ export const kmsServiceFactory = ({
|
|||||||
|
|
||||||
const publicKeyBuffer = signingService(encryptionAlgorithm).getPublicKeyFromPrivateKey(kmsKey);
|
const publicKeyBuffer = signingService(encryptionAlgorithm).getPublicKeyFromPrivateKey(kmsKey);
|
||||||
|
|
||||||
return crypto
|
return (
|
||||||
.createPublicKey({
|
crypto
|
||||||
key: publicKeyBuffer,
|
.createPublicKey({
|
||||||
format: "pem",
|
key: publicKeyBuffer,
|
||||||
type: "spki"
|
format: "pem",
|
||||||
})
|
type: "spki"
|
||||||
.export({ type: "spki", format: "pem" }) as string; // format 'pem' makes it a string
|
})
|
||||||
|
// 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">) => {
|
const signWithKmsKey = async ({ kmsId }: Pick<TSignWithKmsDTO, "kmsId">) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user