diff --git a/backend/src/services/certificate-authority/internal/internal-certificate-authority-service.ts b/backend/src/services/certificate-authority/internal/internal-certificate-authority-service.ts index d165d4d14..af14447a5 100644 --- a/backend/src/services/certificate-authority/internal/internal-certificate-authority-service.ts +++ b/backend/src/services/certificate-authority/internal/internal-certificate-authority-service.ts @@ -1209,6 +1209,10 @@ export const internalCertificateAuthorityServiceFactory = ({ ca = await certificateAuthorityDAL.findByIdWithAssociatedCa(certificateTemplate.caId); } + if (!ca) { + throw new NotFoundError({ message: `Internal CA with ID '${caId}' not found` }); + } + if (!ca?.internalCa?.id) { throw new NotFoundError({ message: `Internal CA with ID '${caId}' not found` }); } @@ -1561,6 +1565,10 @@ export const internalCertificateAuthorityServiceFactory = ({ ca = await certificateAuthorityDAL.findByIdWithAssociatedCa(certificateTemplate.caId); } + if (!ca) { + throw new NotFoundError({ message: `Internal CA with ID '${caId}' not found` }); + } + if (!ca?.internalCa?.id) { throw new NotFoundError({ message: `Internal CA with ID '${caId}' not found` }); }