Encryption & Rotation
This page covers API key security, including encryption configuration and credential rotation best practices.
Encryption and Security
Default Encryption
API keys are encrypted before being stored in the MLflow backend database. For local development, MLflow uses a default passphrase if none is configured. This is acceptable for development or single-user deployments.
Production Encryption Setup
For production environments, configure a custom encryption passphrase:
# Generate a secure passphrase
python -c "import secrets; print(secrets.token_urlsafe(32))"
# Set the passphrase as an environment variable before starting the server
export MLFLOW_CRYPTO_KEK_PASSPHRASE="your-secure-passphrase-here"
# Start the MLflow server
mlflow server --port 5000
File-based tracking stores are not supported by the AI Gateway. The gateway requires a SQL-based backend store (SQLite, PostgreSQL, MySQL, or MSSQL).
Rotating Provider API Keys
When you need to rotate credentials from your LLM provider for security purposes:
Simple Rotation (Zero-Downtime)
This approach updates credentials in place with no service interruption:
- Navigate to the API Keys tab in the Gateway UI
- Locate the key you want to rotate
- Click the Edit button
- Update the credential value with your new API key from the provider
- Click Save
All endpoints using this API key will automatically use the new credentials without requiring any configuration changes or server restarts.
Advanced Rotation (With Rollback Capability)
For mission-critical deployments where you want a rollback path:
- Create a new API key with the rotated credentials (e.g.,
my-openai-key-v2) - Update your endpoints to use the new API key
- Monitor your endpoints to ensure they're working correctly
- Delete the old API key once you've verified the rotation was successful
This approach allows you to quickly revert to the old key if issues arise.
Rotating the Encryption Passphrase
The encryption passphrase is the master secret used to encrypt all stored API keys in the database. You should rotate this periodically for security best practices.
Prerequisites
- Direct database access
- Ability to stop the MLflow server
- Current KEK passphrase and version
Rotation Process
-
Stop the MLflow server to ensure atomicity:
bash# Example: systemctl stop mlflow-server -
Set current environment variables (if not already configured):
bashexport MLFLOW_CRYPTO_KEK_PASSPHRASE="current-passphrase"
export MLFLOW_CRYPTO_KEK_VERSION="1" # Current version -
Run the rotation command with your new passphrase:
bashmlflow crypto rotate-kek --new-passphrase "new-passphrase"The command will re-wrap all encryption keys with the new KEK. The API key values themselves are not re-encrypted, making this efficient even with many secrets.
-
Update deployment configuration with BOTH new values:
bashexport MLFLOW_CRYPTO_KEK_PASSPHRASE="new-passphrase"
export MLFLOW_CRYPTO_KEK_VERSION="2" # Incremented version -
Restart the MLflow server with the updated configuration.
You must update BOTH MLFLOW_CRYPTO_KEK_PASSPHRASE and MLFLOW_CRYPTO_KEK_VERSION environment variables. Failure to update both will cause decryption failures when the server attempts to read stored API keys.