usebruno/bruno · error · Error

pfxFilePath is required for pfx type

Error message

pfxFilePath is required for pfx type

What it means

When a client-cert entry has type 'pfx', the loader requires clientCert.pfxFilePath to be set; a falsy value throws before any read.

Source

Thrown at packages/bruno-requests/src/utils/http-https-agents.ts:303

            }
            certFilePath = path.isAbsolute(certFilePath) ? certFilePath : path.join(collectionPath, certFilePath);
            let keyFilePath = clientCert?.keyFilePath;
            if (!keyFilePath) {
              throw new Error('keyFilePath is required for cert type');
            }
            keyFilePath = path.isAbsolute(keyFilePath) ? keyFilePath : path.join(collectionPath, keyFilePath);

            certsConfig.cert = fs.readFileSync(certFilePath);
            certsConfig.key = fs.readFileSync(keyFilePath);
          } catch (err: any) {
            console.error('Error reading cert/key file', err);
            throw new Error(`Error reading cert/key file: ${err.message}`);
          }
        } else if (type === 'pfx') {
          try {
            let pfxFilePath = clientCert?.pfxFilePath;
            if (!pfxFilePath) {
              throw new Error('pfxFilePath is required for pfx type');
            }
            pfxFilePath = path.isAbsolute(pfxFilePath) ? pfxFilePath : path.join(collectionPath, pfxFilePath);
            certsConfig.pfx = fs.readFileSync(pfxFilePath);
          } catch (err: any) {
            console.error('Error reading pfx file', err);
            throw new Error(`Error reading pfx file: ${err.message}`);
          }
        }
        certsConfig.passphrase = clientCert.passphrase;
        break;
      }
    }
  }

  /**
   * Proxy configuration
   *
   * Preferences proxyMode has four possible values: on, off, system, pac

View on GitHub (pinned to 9bdd81c7bd)

Solutions

  1. Select a .pfx/.p12 file for the entry.
  2. Populate pfxFilePath in the stored config.
  3. Disable the entry until the pfx file is available.

Example fix

// before
{ domain:'api.example.com', type:'pfx', passphrase:'pw' } // no pfxFilePath

// after
{ domain:'api.example.com', type:'pfx', pfxFilePath:'/c.pfx', passphrase:'pw' }
Defensive patterns

Strategy: validation

Validate before calling

for (const cc of clientCertificates?.certs ?? []) {
  if (!cc.disabled && cc.type === 'pfx' && !cc.pfxFilePath) throw new Error(`pfxFilePath missing for domain ${cc.domain}`);
}

Type guard

function isValidPfxEntry(c): boolean { return c?.type === 'pfx' ? !!c?.pfxFilePath : true; }

Prevention

When it happens

Trigger: A clientCertificates entry matches the request domain, is enabled, type is 'pfx', but pfxFilePath is empty/undefined.

Common situations: User switched the entry type to 'pfx' but did not select the .pfx/.p12 file; config hand-edited and the key dropped; import from a schema that named the field differently.

Related errors


AI-assisted analysis of usebruno/bruno@9bdd81c7bd (2026-08-13). Data as JSON: /api/errors/05a392d23362662f. Report an issue: GitHub.