Skip to content

Fix compose-tls for certs with passphrase#2667

Merged
crivetimihai merged 3 commits intomainfrom
fix-oauth
Feb 6, 2026
Merged

Fix compose-tls for certs with passphrase#2667
crivetimihai merged 3 commits intomainfrom
fix-oauth

Conversation

@madhav165
Copy link
Copy Markdown
Collaborator

@madhav165 madhav165 commented Feb 3, 2026

🐛 Bug-fix PR

Closes #2679


📌 Summary

Adds support for passphrase-protected TLS private keys in docker-compose.yml. Previously, users with encrypted certificates had to manually decrypt them before use.

Closes #XXX

🔁 Reproduction Steps

  1. Generate a passphrase-protected certificate:
    make certs-passphrase  # Enter passphrase when prompted
  2. Run make compose-tls
  3. Result: nginx fails to start - cannot read encrypted key

🐞 Root Cause

The cert_init service only checked for existing cert.pem/key.pem files and generated new self-signed certs if missing. It had no mechanism to handle passphrase-protected keys (key-encrypted.pem), and nginx cannot natively read encrypted private keys.

💡 Fix Description

Enhanced cert_init to automatically decrypt passphrase-protected keys:

  • Detects key-encrypted.pem + KEY_FILE_PASSWORD env var
  • Decrypts to key.pem using openssl rsa before nginx starts
  • Preserves original encrypted key for security
  • Added clear logging: "🔓 Decrypting passphrase-protected key..."
  • Updated docs with three certificate options (unencrypted, encrypted, self-signed with passphrase)

🧪 Verification

Check Command Status
Lint suite make lint pass
Unit tests make test pass

📐 MCP Compliance (if relevant)

  • Matches current MCP spec
  • No breaking change to MCP clients

✅ Checklist

  • Code formatted (make black isort pre-commit)
  • No secrets/credentials committed

@madhav165 madhav165 marked this pull request as draft February 3, 2026 09:36
@madhav165 madhav165 marked this pull request as ready for review February 3, 2026 17:00
@crivetimihai
Copy link
Copy Markdown
Member

Clean fix with thorough documentation. The auto-decrypt approach in cert_init is the right pattern since nginx doesn't support passphrase-protected keys natively. CI is all green.

LGTM — ready to merge.

@crivetimihai crivetimihai self-assigned this Feb 4, 2026
madhav165 and others added 3 commits February 6, 2026 00:47
Signed-off-by: Madhav Kandukuri <madhav165@gmail.com>
Signed-off-by: Madhav Kandukuri <madhav165@gmail.com>
- Use env:KEY_FILE_PASSWORD instead of pass: to avoid exposing
  password in process listings
- Add validation to ensure cert.pem exists when key-encrypted.pem
  is provided, preventing silent key overwrite with self-signed cert

Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>
@crivetimihai crivetimihai merged commit 1460d43 into main Feb 6, 2026
39 checks passed
@crivetimihai crivetimihai deleted the fix-oauth branch February 6, 2026 07:04
kcostell06 pushed a commit to kcostell06/mcp-context-forge that referenced this pull request Feb 24, 2026
* Fix compose-tls for certs with passphrase
Signed-off-by: Madhav Kandukuri <madhav165@gmail.com>

* Update documentation
Signed-off-by: Madhav Kandukuri <madhav165@gmail.com>

* fix: improve security and validation for passphrase-protected keys

- Use env:KEY_FILE_PASSWORD instead of pass: to avoid exposing
  password in process listings
- Add validation to ensure cert.pem exists when key-encrypted.pem
  is provided, preventing silent key overwrite with self-signed cert

Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>

---------

Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>
Co-authored-by: Mihai Criveti <crivetimihai@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: TLS profile doesn't support passphrase-protected certificates

2 participants