Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

misc: resolved export for pkcs12

Sheen Capadngan96d36bf1a6ef
diff --git a/backend/src/services/certificate/certificate-service.ts b/backend/src/services/certificate/certificate-service.ts
index 983bf3f46d..44be47fc79 100644
--- a/backend/src/services/certificate/certificate-service.ts
+++ b/backend/src/services/certificate/certificate-service.ts
@@ -731,7 +731,7 @@ export const certificateServiceFactory = ({
// Get certificate bundle (certificate, chain, private key)
const { certificate, certificateChain, privateKey } = await getCertBundle({
- serialNumber,
+ id: cert.id,
actor,
actorId,
actorAuthMethod,
diff --git a/frontend/src/hooks/api/certificates/mutations.tsx b/frontend/src/hooks/api/certificates/mutations.tsx
index aca7524589..54aa3c3b46 100644
--- a/frontend/src/hooks/api/certificates/mutations.tsx
+++ b/frontend/src/hooks/api/certificates/mutations.tsx
@@ -149,10 +149,10 @@ export const useUpdateRenewalConfig = () => {
export const useDownloadCertPkcs12 = () => {
return useMutation<void, object, TDownloadPkcs12DTO>({
- mutationFn: async ({ serialNumber, projectSlug, password, alias }) => {
+ mutationFn: async ({ certificateId, projectSlug, password, alias }) => {
try {
const response = await apiRequest.post(
- `/api/v1/cert-manager/certificates/${serialNumber}/pkcs12`,
+ `/api/v1/cert-manager/certificates/${certificateId}/pkcs12`,
{
password,
alias
@@ -168,7 +168,7 @@ export const useDownloadCertPkcs12 = () => {
const url = window.URL.createObjectURL(blob);
const link = document.createElement("a");
link.href = url;
- link.download = `certificate-${serialNumber}.p12`;
+ link.download = `certificate-${certificateId}.p12`;
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
diff --git a/frontend/src/hooks/api/certificates/types.ts b/frontend/src/hooks/api/certificates/types.ts
index 953ae818f6..2e9b70cae5 100644
--- a/frontend/src/hooks/api/certificates/types.ts
+++ b/frontend/src/hooks/api/certificates/types.ts
@@ -74,7 +74,7 @@ export type TUpdateRenewalConfigDTO = {
};
export type TDownloadPkcs12DTO = {
- serialNumber: string;
+ certificateId: string;
projectSlug: string;
password: string;
alias: string;
diff --git a/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateExportModal.tsx b/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateExportModal.tsx
index 3916477a15..d16a1ac3f5 100644
--- a/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateExportModal.tsx
+++ b/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateExportModal.tsx
@@ -21,7 +21,13 @@ type Props = {
) => void;
onFormatSelected: (
format: "pem" | "pkcs12",
- serialNumber: string,
+ {
+ certificateId,
+ serialNumber
+ }: {
+ certificateId: string;
+ serialNumber: string;
+ },
options?: ExportOptions
) => void;
};
@@ -42,8 +48,11 @@ export const CertificateExportModal = ({ popUp, handlePopUpToggle, onFormatSelec
alias: ""
});
- const serialNumber =
- (popUp?.certificateExport?.data as { serialNumber: string })?.serialNumber || "";
+ const { certificateId, serialNumber } =
+ (popUp?.certificateExport?.data as {
+ certificateId: string;
+ serialNumber: string;
+ }) || {};
// Reset form whenever the modal opens
useEffect(() => {
@@ -64,14 +73,21 @@ export const CertificateExportModal = ({ popUp, handlePopUpToggle, onFormatSelec
};
const handleExport = () => {
- if (serialNumber && isFormValid()) {
+ if ((certificateId || serialNumber) && isFormValid()) {
const options: ExportOptions = {};
if (selectedFormat === "pkcs12") {
options.pkcs12 = pkcs12Options;
}
- onFormatSelected(selectedFormat, serialNumber, options);
+ onFormatSelected(
+ selectedFormat,
+ {
+ certificateId,
+ serialNumber
+ },
+ options
+ );
handlePopUpToggle("certificateExport", false);
}
};
@@ -151,7 +167,7 @@ export const CertificateExportModal = ({ popUp, handlePopUpToggle, onFormatSelec
colorSchema="primary"
leftIcon={<FontAwesomeIcon icon={faDownload} />}
onClick={handleExport}
- disabled={!serialNumber || !isFormValid()}
+ disabled={!(certificateId || serialNumber) || !isFormValid()}
>
Export {selectedFormat.toUpperCase()}
</Button>
diff --git a/frontend/src/pages/cert-manager/CertificatesPage/components/CertificatesSection.tsx b/frontend/src/pages/cert-manager/CertificatesPage/components/CertificatesSection.tsx
index 36c4b4f714..54967b2b28 100644
--- a/frontend/src/pages/cert-manager/CertificatesPage/components/CertificatesSection.tsx
+++ b/frontend/src/pages/cert-manager/CertificatesPage/components/CertificatesSection.tsx
@@ -57,7 +57,13 @@ export const CertificatesSection = () => {
const handleCertificateExport = async (
format: "pem" | "pkcs12",
- serialNumber: string,
+ {
+ certificateId,
+ serialNumber
+ }: {
+ certificateId: string;
+ serialNumber: string;
+ },
options?: ExportOptions
) => {
if (format === "pem") {
@@ -75,7 +81,7 @@ export const CertificatesSection = () => {
try {
await downloadCertPkcs12({
- serialNumber,
+ certificateId,
projectSlug: currentProject.slug,
password: options.pkcs12.password,
alias: options.pkcs12.alias
diff --git a/frontend/src/pages/cert-manager/CertificatesPage/components/CertificatesTable.tsx b/frontend/src/pages/cert-manager/CertificatesPage/components/CertificatesTable.tsx
index e6d10bcd60..b4defeb3a9 100644
--- a/frontend/src/pages/cert-manager/CertificatesPage/components/CertificatesTable.tsx
+++ b/frontend/src/pages/cert-manager/CertificatesPage/components/CertificatesTable.tsx
@@ -277,6 +277,7 @@ export const CertificatesTable = ({ handlePopUpOpen }: Props) => {
)}
onClick={async () =>
handlePopUpOpen("certificateExport", {
+ certificateId: certificate.id,
serialNumber: certificate.serialNumber
})
}