Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
Address PR comments
Carlos Monastyrski9f27d1b04fe1
diff --git a/backend/src/ee/services/pki-scep/pki-scep-message-parser.test.ts b/backend/src/ee/services/pki-scep/pki-scep-message-parser.test.tsindex c6c911f2f0..97b904121a 100644--- a/backend/src/ee/services/pki-scep/pki-scep-message-parser.test.ts+++ b/backend/src/ee/services/pki-scep/pki-scep-message-parser.test.ts@@ -295,7 +295,9 @@ describe("parseScepMessage key transport", () => {try {decryptedCsr = parseScepMessage(message, exportPkcs8(ra)).csr;} catch (err) {- expect((err as Error).message).toBe("Failed to decrypt SCEP enveloped data");+ expect((err as Error).message).toBe(+ `Failed to decrypt SCEP enveloped data (key encryption algorithm ${KEY_TRANSPORT_OIDS.rsaesOaep})`+ );}expect(decryptedCsr?.equals(csr) ?? false).toBe(false);diff --git a/backend/src/ee/services/pki-scep/pki-scep-message-parser.ts b/backend/src/ee/services/pki-scep/pki-scep-message-parser.tsindex 23a080d9bf..cfbd10de8a 100644--- a/backend/src/ee/services/pki-scep/pki-scep-message-parser.ts+++ b/backend/src/ee/services/pki-scep/pki-scep-message-parser.ts@@ -271,9 +271,12 @@ enum KeyTransportScheme {RsaOaep = "rsa-oaep"}-type TKeyTransport =+type TKeyTransport = { algorithmOid?: string } & (| { scheme: KeyTransportScheme.RsaPkcs1 }- | { scheme: KeyTransportScheme.RsaOaep; hash: string; label?: Buffer };+ | { scheme: KeyTransportScheme.RsaOaep; hash: string; label?: Buffer }+);++const MAX_REPORTED_OID_LENGTH = 64;const OAEP_P_SOURCE_TAG_NUMBER = 2;@@ -301,8 +304,9 @@ const parseKeyTransportAlgorithm = (keyEncryptionAlgorithm: asn1js.BaseBlock): Treturn { scheme: KeyTransportScheme.RsaPkcs1 };}+ const algorithmOid = algorithm.algorithmId.slice(0, MAX_REPORTED_OID_LENGTH);if (algorithm.algorithmId !== KEY_TRANSPORT_OIDS.rsaesOaep) {- return { scheme: KeyTransportScheme.RsaPkcs1 };+ return { scheme: KeyTransportScheme.RsaPkcs1, algorithmOid };}const { algorithmParams } = algorithm as { algorithmParams: unknown };@@ -325,7 +329,7 @@ const parseKeyTransportAlgorithm = (keyEncryptionAlgorithm: asn1js.BaseBlock): TparamElement.idBlock.tagClass === 3 && paramElement.idBlock.tagNumber === OAEP_P_SOURCE_TAG_NUMBER) ?? false;if (!hasExplicitPSource) {- return { scheme: KeyTransportScheme.RsaOaep, hash };+ return { scheme: KeyTransportScheme.RsaOaep, hash, algorithmOid };}const { pSourceAlgorithm } = oaepParams;@@ -336,8 +340,8 @@ const parseKeyTransportAlgorithm = (keyEncryptionAlgorithm: asn1js.BaseBlock): T});}- const labelBytes = Buffer.from(label.valueBlock.valueHexView);- return { scheme: KeyTransportScheme.RsaOaep, hash, label: labelBytes.length ? labelBytes : undefined };+ const labelBytes = Buffer.from(label.getValue());+ return { scheme: KeyTransportScheme.RsaOaep, hash, label: labelBytes.length ? labelBytes : undefined, algorithmOid };};const decryptEnvelopedDataRaw = (@@ -389,8 +393,13 @@ const decryptEnvelopedDataRaw = (throw new BadRequestError({ message: "No RecipientInfo found in EnvelopedData" });}- const firstRecipientInfo = recipientInfosSet.valueBlock.value[0] as asn1js.Sequence;- const ktri = firstRecipientInfo.valueBlock.value;+ const firstRecipientInfo = recipientInfosSet.valueBlock.value[0];+ const ktri = firstRecipientInfo instanceof asn1js.Sequence ? firstRecipientInfo.valueBlock.value : [];+ if (ktri.length !== 4) {+ throw new BadRequestError({+ message: "The SCEP request's recipient info is malformed, so its request could not be decrypted."+ });+ }// The encryptedKey is the LAST element of KeyTransRecipientInfo// Per RFC 5652: version, rid, keyEncryptionAlgorithm, encryptedKey@@ -458,7 +467,9 @@ const decryptEnvelopedDataRaw = (try {plainText = symmetricDecrypt(encryptedContent, contentEncryptionKey, iv, cipherOid);} catch {- throw new BadRequestError({ message: "Failed to decrypt SCEP enveloped data" });+ throw new BadRequestError({+ message: `Failed to decrypt SCEP enveloped data (key encryption algorithm ${keyTransport.algorithmOid ?? "unreadable"})`+ });}return { plainText, cipherOid };diff --git a/docs/documentation/platform/pki/applications/enrollment-methods/scep.mdx b/docs/documentation/platform/pki/applications/enrollment-methods/scep.mdxindex 0d51d00cdb..acb721bcb3 100644--- a/docs/documentation/platform/pki/applications/enrollment-methods/scep.mdx+++ b/docs/documentation/platform/pki/applications/enrollment-methods/scep.mdx@@ -45,6 +45,10 @@ https://app.infisical.com/scep/{profile_id}/pkiclient.exeFor self-hosted Infisical instances, replace `app.infisical.com` with your instance's domain.+<Note>+ Windows adds `/pkiclient.exe` to the SCEP server URL itself. If you configure Windows devices, including through an MDM tool such as Microsoft Intune, remove `/pkiclient.exe` from the end of the URL. Other SCEP clients, such as Apple devices and sscep, use the full URL.+</Note>+## Guides<CardGroup cols={2}>diff --git a/docs/documentation/platform/pki/guides/applications/microsoft-intune-scep.mdx b/docs/documentation/platform/pki/guides/applications/microsoft-intune-scep.mdxindex 1417437590..256205f0a3 100644--- a/docs/documentation/platform/pki/guides/applications/microsoft-intune-scep.mdx+++ b/docs/documentation/platform/pki/guides/applications/microsoft-intune-scep.mdx@@ -268,9 +268,9 @@ This profile gives each device the address of your endpoint and a single-use cha- <Warning>+ <Note>On Windows, remove `/pkiclient.exe` from the end of the URL. Windows adds `/pkiclient.exe` to the URL itself, so if you leave it in, the device requests `.../pkiclient.exe/pkiclient.exe` and never enrolls. On Apple platforms, keep the full URL.- </Warning>+ </Note>**Certificate validity period** and **Extended key usage** are the two you're mirroring from [Step 1](#step-1-prepare-the-certificate-profile-in-infisical). Intune reports the enrollment as successful without comparing either one against the certificate it receives, so a mismatch here is never flagged.@@ -294,7 +294,7 @@ This profile gives each device the address of your endpoint and a single-use cha</Steps><Note>- Intune configuration profiles are platform-specific, so each platform you support needs its own trusted certificate profile and SCEP certificate profile. Supporting Macs and Windows machines means four profiles. The Infisical side is shared, and all of them point at the same SCEP endpoint URL.+ Intune configuration profiles are platform-specific, so each platform you support needs its own trusted certificate profile and SCEP certificate profile. Supporting Macs and Windows machines means four profiles. The Infisical side is shared, so every profile uses the same SCEP endpoint URL, with `/pkiclient.exe` removed on Windows.</Note>## Step 5: Verify enrollment@@ -326,6 +326,11 @@ Infisical's **Allow cert-based renewal** option stays off for Intune validation,## Troubleshooting<AccordionGroup>+ <Accordion title="A Windows device never enrolls and the audit log shows no SCEP enrollment event">+ The **SCEP Server URLs** value in the Windows profile most likely still ends in `/pkiclient.exe`. Windows adds `/pkiclient.exe` to the URL itself, so the device requests a URL that doesn't exist and stops before it sends a certificate request.++ Remove `/pkiclient.exe` from the end of the URL in the Windows SCEP profile, then sync the device. To confirm which URL the device used, open Event Viewer on the device and go to **Applications and Services Logs** > **Microsoft** > **Windows** > **DeviceManagement-Enterprise-Diagnostics-Provider** > **Admin**. Event 307 shows the SCEP server URL the device tried.+ </Accordion><Accordion title="Enrollment fails immediately with a validation error">Infisical asked Intune to validate the challenge and Intune declined. Work through these in order:@@ -357,7 +362,7 @@ Infisical's **Allow cert-based renewal** option stays off for Intune validation,Intune validation requires a profile backed by an internal CA. External CAs issue asynchronously, and Intune has no pending state to wait in, so Infisical rejects the combination when you configure the enrollment.</Accordion><Accordion title="Do I need separate profiles for each device platform?">- Yes. Intune configuration profiles are platform-specific, so each platform needs its own trusted certificate profile and SCEP certificate profile. The Infisical side is shared, and every platform can point at the same SCEP endpoint URL.+ Yes. Intune configuration profiles are platform-specific, so each platform needs its own trusted certificate profile and SCEP certificate profile. The Infisical side is shared, so every platform uses the same SCEP endpoint URL, with `/pkiclient.exe` removed on Windows.Which SCEP profile fields Intune offers also depends on the platform. **Key storage provider** appears on Windows, **Hash algorithm** on Windows and Android, and **Deployment Channel** on Apple platforms. See [Use SCEP certificate profiles with Microsoft Intune](https://learn.microsoft.com/en-us/mem/intune/protect/certificates-profile-scep) for the full field list.</Accordion>diff --git a/frontend/src/pages/cert-manager/ApplicationDetailsByIDPage/components/ConfigureEnrollmentModal.tsx b/frontend/src/pages/cert-manager/ApplicationDetailsByIDPage/components/ConfigureEnrollmentModal.tsxindex d15afc2d28..b8620d4641 100644--- a/frontend/src/pages/cert-manager/ApplicationDetailsByIDPage/components/ConfigureEnrollmentModal.tsx+++ b/frontend/src/pages/cert-manager/ApplicationDetailsByIDPage/components/ConfigureEnrollmentModal.tsx@@ -1010,7 +1010,7 @@ const ScepPanel = ({<CopyableFieldlabel="SCEP endpoint URL"value={initial.scepEndpointUrl}- helper="Configure your MDM or SCEP client to point at this URL."+ helper="Configure your MDM or SCEP client to point at this URL. For Windows devices, remove /pkiclient.exe from the end."/>{initial.challengeType === ScepChallengeType.DYNAMIC && initial.challengeEndpointUrl ? (<CopyableField