examples/provider-http/tls/README.md
You can run this example with:
npx promptfoo@latest init --example provider-http/tls
cd provider-http/tls
This example demonstrates how to configure the HTTP provider with TLS/SSL certificates for mutual TLS (mTLS) authentication.
The HTTP provider supports multiple certificate formats for mutual TLS authentication:
Each format can be provided via:
The simplest approach - separate certificate and key files:
tls:
certPath: '/path/to/client-cert.pem'
keyPath: '/path/to/client-key.pem'
When your private key is password-protected (starts with BEGIN ENCRYPTED PRIVATE KEY):
tls:
certPath: '/path/to/client-cert.pem'
keyPath: '/path/to/client-key-encrypted.pem'
passphrase: 'your-key-password'
Embed certificates directly in your configuration:
tls:
cert: |
-----BEGIN CERTIFICATE-----
MIIDxTCCAq2gAwIBAgIJAL...
-----END CERTIFICATE-----
key: |
-----BEGIN PRIVATE KEY-----
MIIEvQIBADANBgkqhkiG9w0B...
-----END PRIVATE KEY-----
Reference a PFX file on the filesystem:
tls:
pfxPath: '/path/to/certificate.pfx'
passphrase: 'your-passphrase'
Embed the certificate directly in your configuration:
tls:
pfx: 'MIIJKQIBAzCCCO8GCSqGSIb3DQEHA...' # Base64-encoded PFX
passphrase: 'your-passphrase'
Store sensitive certificates in environment variables:
tls:
pfx: '{{env.PFX_CERTIFICATE_BASE64}}'
passphrase: '{{env.PFX_PASSPHRASE}}'
To use inline PFX certificates, you need to convert your PFX file to base64:
base64 -i certificate.pfx -o certificate.b64
certutil -encode certificate.pfx certificate.b64
Then copy the content (excluding the BEGIN/END headers) to use as the pfx value.
rejectUnauthorized: true in productionexport PFX_PASSPHRASE="your-passphrase"
export PFX_CERTIFICATE_BASE64="your-base64-cert"
promptfoo eval
| Option | Description |
|---|---|
cert | Inline PEM certificate content |
certPath | Path to PEM certificate file |
key | Inline PEM private key content |
keyPath | Path to PEM private key file |
pfx | Inline PFX certificate (base64-encoded string or Buffer) |
pfxPath | Path to PFX file on disk |
passphrase | Password for encrypted PEM private key or PFX certificate |
ca | CA certificate content for server verification |
caPath | Path to CA certificate file |
rejectUnauthorized | Verify server certificates (always true in production) |
minVersion | Minimum TLS version (e.g., 'TLSv1.2') |
maxVersion | Maximum TLS version (e.g., 'TLSv1.3') |
ciphers | Cipher suite specification |
If you get an error about invalid PFX format:
If the connection is refused:
If certificate verification fails:
ca or caPathrejectUnauthorized: false (never in production)