Skip to content

fix(checkoutservice): Option 2 — Mutual TLS (mTLS) with custom certs#3

Open
mikecstone wants to merge 1 commit into
masterfrom
fix/grpc-mtls
Open

fix(checkoutservice): Option 2 — Mutual TLS (mTLS) with custom certs#3
mikecstone wants to merge 1 commit into
masterfrom
fix/grpc-mtls

Conversation

@mikecstone

Copy link
Copy Markdown
Owner

Summary

  • Adds loadTLSCredentials() which reads a CA cert, client cert, and client key from environment variables (TLS_CA_CERT_PATH, TLS_CLIENT_CERT_PATH, TLS_CLIENT_KEY_PATH) and configures TLS 1.3 mTLS
  • Stores credentials on the checkoutService struct and uses them for all 8 outbound service connections
  • Removes grpc.WithInsecure() entirely
  • Fixes context.TODO()ctx in convertCurrency

Trade-offs

Pros:

  • Full mutual TLS — both the server and this service authenticate each other, satisfying zero-trust requirements
  • TLS 1.3 minimum enforced in code, not just policy
  • Cert paths are configurable via env vars, making it easy to mount Kubernetes secrets or use cert-manager

Cons:

  • Requires provisioning and rotating client certs for the checkoutservice itself
  • Each downstream service must also be updated to require and validate client certs
  • More operational overhead than Option 1

Required environment variables

Variable Description
TLS_CA_CERT_PATH Path to the CA cert PEM that signed the server certs
TLS_CLIENT_CERT_PATH Path to this service's client certificate PEM
TLS_CLIENT_KEY_PATH Path to this service's client private key PEM

When to use this

Best fit for production environments with a zero-trust posture, an internal PKI (e.g. cert-manager, Vault PKI), and where all microservices are being hardened together.

Test plan

  • Mount valid cert/key/CA files and confirm service starts without error
  • Confirm PlaceOrder end-to-end succeeds with valid mTLS certs
  • Confirm connection is rejected when an invalid or expired client cert is presented
  • Confirm connection is rejected when server cert is signed by an untrusted CA

🤖 Generated with Claude Code

Adds loadTLSCredentials() which loads a CA cert, client cert, and client
key from environment variables (TLS_CA_CERT_PATH, TLS_CLIENT_CERT_PATH,
TLS_CLIENT_KEY_PATH) and configures TLS 1.3 mTLS. The credentials are
stored on checkoutService and used for all 8 service connections, removing
grpc.WithInsecure() entirely. Also fixes context.TODO() -> ctx in
convertCurrency to restore proper timeout/cancellation propagation.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@ox-security

ox-security Bot commented May 17, 2026

Copy link
Copy Markdown

OX Security Logo

OX Security reviewed this pull request — nothing to fix.

No issues found

Branch fix/grpc-mtlsmaster

View scan in OX Security →

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant