Are you sure you want to delete this access key?
You can run this example with:
npx promptfoo@latest init --example http-provider-auth-signature-pfx
This example demonstrates how to setup authentication with an HTTP provider using certificates for cryptographic signature validation. You can use either:
npm install
# First, create a private key and certificate
openssl req -x509 -newkey rsa:2048 -keyout private.key -out certificate.crt \
-days 365 -nodes -subj "/CN=PromptFoo Test/O=Test/C=US"
# Then, create a PFX file from the key and certificate
openssl pkcs12 -export -out certificate.pfx -inkey private.key -in certificate.crt \
-passout pass:password
# Clean up temporary files
rm private.key certificate.crt
# Create a private key and certificate (keep both files)
openssl req -x509 -newkey rsa:2048 -keyout private.key -out certificate.crt \
-days 365 -nodes -subj "/CN=PromptFoo Test/O=Test/C=US"
# No cleanup needed - both files are used directly
npm start
The example includes two configuration files demonstrating different certificate formats:
promptfooconfig.yaml
)signatureAuth:
type: pfx
pfxPath: ./certificate.pfx
pfxPassword: password
signatureAlgorithm: SHA256
signatureValidityMs: 300000
signatureDataTemplate: 'promptfoo-app{{signatureTimestamp}}'
promptfooconfig-crt-key.yaml
)signatureAuth:
type: pfx
certPath: ./certificate.crt
keyPath: ./private.key
signatureAlgorithm: SHA256
signatureValidityMs: 300000
signatureDataTemplate: 'promptfoo-app{{signatureTimestamp}}'
Important: In production, use environment variables for passwords and secure key management practices.
Note, for this example to work, you will need to set the environment variable NODE_TLS_REJECT_UNAUTHORIZED=0
, as this cert is self-signed.
# Run test cases with PFX certificate
NODE_TLS_REJECT_UNAUTHORIZED=0 promptfoo eval --no-cache
# Or run with separate CRT/KEY files
NODE_TLS_REJECT_UNAUTHORIZED=0 promptfoo eval -c promptfooconfig-crt-key.yaml --no-cache
# View results
promptfoo view
IMPORTANT: Be sure to run with --no-cache
when testing! Otherwise it may cache responses from good signatures.
signature
, timestamp
, client-id
)This example uses hardcoded values for simplicity. In production, you should use:
PROMPTFOO_PFX_PASSWORD
- Password for the PFX certificate file (when using PFX option)PFX (Personal Information Exchange) is a binary format for storing cryptographic objects. It's commonly used on Windows systems and can contain:
This format is password-protected and provides a convenient way to transport certificates and private keys together.
Alternatively, you can use separate certificate and key files:
This approach is common in Unix/Linux environments and provides flexibility in managing certificates and keys separately.
Both formats are supported by the promptfoo HTTP provider for cryptographic signature generation and verification.
Press p or to see the previous file or, n or to see the next file
Browsing data directories saved to S3 is possible with DAGsHub. Let's configure your repository to easily display your data in the context of any commit!
promptfoo is now integrated with AWS S3!
Are you sure you want to delete this access key?
Browsing data directories saved to Google Cloud Storage is possible with DAGsHub. Let's configure your repository to easily display your data in the context of any commit!
promptfoo is now integrated with Google Cloud Storage!
Are you sure you want to delete this access key?
Browsing data directories saved to Azure Cloud Storage is possible with DAGsHub. Let's configure your repository to easily display your data in the context of any commit!
promptfoo is now integrated with Azure Cloud Storage!
Are you sure you want to delete this access key?
Browsing data directories saved to S3 compatible storage is possible with DAGsHub. Let's configure your repository to easily display your data in the context of any commit!
promptfoo is now integrated with your S3 compatible storage!
Are you sure you want to delete this access key?