mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-14 14:34:09 +00:00
feat(fips): requested changes
This commit is contained in:
@@ -86,10 +86,10 @@ export const getCertificateCredentials = async ({
|
||||
});
|
||||
|
||||
try {
|
||||
const skObj = crypto.rawCrypto.createPrivateKey({ key: decryptedPrivateKey, format: "pem", type: "pkcs8" });
|
||||
const skObj = crypto.nativeCrypto.createPrivateKey({ key: decryptedPrivateKey, format: "pem", type: "pkcs8" });
|
||||
const certPrivateKey = skObj.export({ format: "pem", type: "pkcs8" }).toString();
|
||||
|
||||
const pkObj = crypto.rawCrypto.createPublicKey(skObj);
|
||||
const pkObj = crypto.nativeCrypto.createPublicKey(skObj);
|
||||
const certPublicKey = pkObj.export({ format: "pem", type: "spki" }).toString();
|
||||
|
||||
return {
|
||||
|
||||
@@ -373,16 +373,16 @@ export const certificateServiceFactory = ({
|
||||
// Verify private key matches the certificate
|
||||
let privateKey;
|
||||
try {
|
||||
privateKey = crypto.rawCrypto.createPrivateKey(privateKeyPem);
|
||||
privateKey = crypto.nativeCrypto.createPrivateKey(privateKeyPem);
|
||||
} catch (err) {
|
||||
throw new BadRequestError({ message: "Invalid private key format" });
|
||||
}
|
||||
|
||||
try {
|
||||
const message = Buffer.from(Buffer.alloc(32));
|
||||
const publicKey = crypto.rawCrypto.createPublicKey(certificatePem);
|
||||
const signature = crypto.rawCrypto.sign(null, message, privateKey);
|
||||
const isValid = crypto.rawCrypto.verify(null, message, publicKey, signature);
|
||||
const publicKey = crypto.nativeCrypto.createPublicKey(certificatePem);
|
||||
const signature = crypto.nativeCrypto.sign(null, message, privateKey);
|
||||
const isValid = crypto.nativeCrypto.verify(null, message, publicKey, signature);
|
||||
|
||||
if (!isValid) {
|
||||
throw new BadRequestError({ message: "Private key does not match certificate" });
|
||||
|
||||
Reference in New Issue
Block a user