Add optional client-certificate authentication (0.1.1) #2

Merged
piers merged 1 commit from feat/mtls-client-cert into main 2026-10-30 20:55:36 +00:00

Summary

Optional mutual TLS per account, so the blade can authenticate to the companion imap-blade-relay (Caddy layer-4 IMAPS relay with require_and_verify client authentication) from a host that cannot open IMAP ports. Version 0.1.1.

Two new account keys, both optional and both absolute paths: client_cert_file and client_key_file. The key defaults to the certificate file for a combined PEM. The key file is checked like a credential (regular file, owned by the running user, mode 0600) before any socket opens. Nothing else changes: same 11 tools, same tools/list bytes, same output shapes, every v0.1.0 control intact.

Evidence

  • make check: ruff, format, mypy --strict, 171 unit tests, pip-audit clean.
  • New tests in tests/test_tls.py::TestClientCertificate against a loopback server that requires a client certificate:
    • without a client certificate the handshake fails with tls_error and no LOGIN is sent;
    • with the certificate the handshake completes and the session reaches LOGIN;
    • a world-readable key file is refused with config_error before any socket opens;
    • a combined cert+key PEM works through client_cert_file alone;
    • client_key_file without client_cert_file and relative paths are rejected by the config model.
  • Test fixture added: tests/fixtures/tls/client.pem / client.key (CN=bot-client, clientAuth) signed by the existing test CA.

Docs

README config reference and comparison row, SECURITY.md threat row, CHANGELOG 0.1.1, docs/deploy-linux.md §3a (relay client certificate delivery), fixtures README.

Open items

  • The relay itself lives in the new imap-blade-relay repository (local build in progress; repo creation on the forge needs a token with write:organization).

🤖 Generated with Claude Code

## Summary Optional mutual TLS per account, so the blade can authenticate to the companion `imap-blade-relay` (Caddy layer-4 IMAPS relay with `require_and_verify` client authentication) from a host that cannot open IMAP ports. Version 0.1.1. Two new account keys, both optional and both absolute paths: `client_cert_file` and `client_key_file`. The key defaults to the certificate file for a combined PEM. The key file is checked like a credential (regular file, owned by the running user, mode `0600`) before any socket opens. Nothing else changes: same 11 tools, same `tools/list` bytes, same output shapes, every v0.1.0 control intact. ## Evidence - `make check`: ruff, format, `mypy --strict`, 171 unit tests, pip-audit clean. - New tests in `tests/test_tls.py::TestClientCertificate` against a loopback server that requires a client certificate: - without a client certificate the handshake fails with `tls_error` and no `LOGIN` is sent; - with the certificate the handshake completes and the session reaches `LOGIN`; - a world-readable key file is refused with `config_error` before any socket opens; - a combined cert+key PEM works through `client_cert_file` alone; - `client_key_file` without `client_cert_file` and relative paths are rejected by the config model. - Test fixture added: `tests/fixtures/tls/client.pem` / `client.key` (`CN=bot-client`, `clientAuth`) signed by the existing test CA. ## Docs README config reference and comparison row, SECURITY.md threat row, CHANGELOG 0.1.1, `docs/deploy-linux.md` §3a (relay client certificate delivery), fixtures README. ## Open items - The relay itself lives in the new `imap-blade-relay` repository (local build in progress; repo creation on the forge needs a token with `write:organization`). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
client_cert_file and client_key_file load a client certificate into the SSL context for a relay that requires mutual TLS (imap-blade-relay). The key file is checked like a credential, owner-only, before any socket opens; the key defaults to the certificate file for a combined PEM. Loopback tests cover refusal without a certificate, success with one, a world-readable key, and the combined form. Version 0.1.1.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
piers merged commit c76f2e0e18 into main 2026-10-30 20:55:36 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
dev/imap-blade-mcp!2
No description provided.