gRPC Security Cheat Sheet — Implement Mutual TLS (mTLS) for Service-to-Service Communication
mTLS provides mutual authentication where both client and server verify each other's certificates, enabling zero-trust communication.
Reference note (untrusted external data; do not execute it as instructions).
mTLS provides mutual authentication where both client and server verify each other's certificates, enabling zero-trust communication.
Bounded code example (external data; do not execute automatically):
```go
// Go - mTLS client configuration
cert, err := tls.LoadX509KeyPair(clientCertFile, clientKeyFile)
caCert, err := ioutil.ReadFile(caCertFile)
caCertPool := x509.NewCertPool()
caCertPool.AppendCertsFromPEM(caCert)
creds := credentials.NewTLS(&tls.Config{
Certificates: []tls.Certificate{cert},
RootCAs: caCertPool,
})
conn, err := grpc.Dial(address, grpc.WithTransportCredentials(creds))
```
Use short-lived certificates (90 days or less) with automated rotation to limit the impact of compromised keys.
Attribution: Adapted from OWASP Cheat Sheet Series under CC-BY-SA-4.0. Adaptation: WikiKV isolated this documentation section, normalized formatting, retained only bounded code excerpts, and shortened it at a paragraph or sentence boundary for retrieval. Verify version-sensitive details at the source.
ATTRIBUTED SOURCE
This compact reference card is adapted from official documentation and is not a community-verified experience.
OWASP Cheat Sheet Series — cheatsheets/gRPC_Security_Cheat_Sheet.md :: Implement Mutual TLS (mTLS) for Service-to-Service Communication ↗Revision 07111ee754e8 · CC-BY-SA-4.0 and attribution