Skip to content

Commit 7a73164

Browse files
committed
docs: Wiki for mTLS
Signed-off-by: [email protected] <[email protected]>
1 parent 13fa934 commit 7a73164

File tree

1 file changed

+48
-140
lines changed

1 file changed

+48
-140
lines changed

docs/03-concepts/14-mutual-tls.md

Lines changed: 48 additions & 140 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
---
2-
layout: default
3-
title: Mutual TLS (mTLS) Authentication
4-
permalink: /docs/concepts/mutual-tls
5-
---
2+
3+
## layout: default title: Mutual TLS (mTLS) Authentication permalink: /docs/concepts/mutual-tls
64

75
# Mutual TLS (mTLS) Authentication
86

@@ -18,8 +16,8 @@ Mutual TLS (mTLS) is an enhanced version of the standard TLS protocol where both
1816

1917
In mTLS, both the client and server have a certificate, and both sides authenticate using their public/private key pair. This bidirectional authentication provides an additional layer of security, ensuring that:
2018

21-
- Clients can verify they're connecting to the legitimate server
22-
- Servers can verify the identity of connecting clients
19+
- Clients can verify they're connecting to the legitimate server
20+
- Servers can verify the identity of connecting clients
2321
- All communication is encrypted end-to-end
2422

2523
---
@@ -33,44 +31,45 @@ The mTLS handshake process involves the following steps:
3331
│ mTLS Handshake Flow │
3432
└─────────────────────────────────────────────────────────────────────────┘
3533
36-
CLIENT SERVER
37-
│ │
38-
│ (1) Client initiates connection │
39-
├─────────────────────────────────────────────────────--─> │
40-
│ │
41-
│ (2) Server sends its certificate │
42-
│ <────────────────────────────────────────────────────── ┤
43-
│ │
44-
│ (3) Client verifies server certificate │
45-
│ ✓ Check signature │
46-
│ ✓ Validate certificate chain │
47-
│ ✓ Check expiration │
48-
│ │
49-
│ (4) Client sends its certificate │
50-
├───────────────────────────────────────────────────--───> │
51-
│ │
52-
│ (5) Server verifies client certificate │
53-
│ ✓ Check signature │
54-
│ ✓ Validate certificate chain │
55-
│ ✓ Check expiration │
56-
│ │
57-
│ (6) Server grants access │
58-
│ <────────────────────────────────────────────────────── ┤
59-
│ │
60-
│ (7) Encrypted TLS connection established │
61-
│ <═══════════════════════════════════════════════════> │
62-
│ All subsequent data is encrypted │
63-
│ │
34+
35+
CLIENT SERVER
36+
│ │
37+
│ (1) Client initiates connection │
38+
├─────────────────────────────────────────────────────--─> │
39+
│ │
40+
│ (2) Server sends its certificate │
41+
│ <────────────────────────────────────────────────────── ┤
42+
│ │
43+
│ (3) Client verifies server certificate │
44+
│ ✓ Check signature │
45+
│ ✓ Validate certificate chain │
46+
│ ✓ Check expiration │
47+
│ │
48+
│ (4) Client sends its certificate │
49+
├───────────────────────────────────────────────────--───> │
50+
│ │
51+
│ (5) Server verifies client certificate │
52+
│ ✓ Check signature │
53+
│ ✓ Validate certificate chain │
54+
│ ✓ Check expiration │
55+
│ │
56+
│ (6) Server grants access │
57+
│ <────────────────────────────────────────────────────── ┤
58+
│ │
59+
│ (7) Encrypted TLS connection established │
60+
│ <═══════════════════════════════════════════════════> │
61+
│ All subsequent data is encrypted │
62+
│ │
6463
```
6564

6665
### Step-by-Step Process
6766

68-
1. **Client connects to server**: The client initiates a connection to the server
69-
2. **Server presents its TLS certificate**: The server sends its certificate to prove its identity
70-
3. **Client verifies the server's certificate**: The client validates the server's certificate against trusted Certificate Authorities (CAs)
71-
4. **Client presents its TLS certificate**: The client sends its own certificate to prove its identity
72-
5. **Server verifies the client's certificate**: The server validates the client's certificate
73-
6. **Server grants access**: Once both certificates are verified, the server allows the connection
67+
1. **Client connects to server**: The client initiates a connection to the server
68+
2. **Server presents its TLS certificate**: The server sends its certificate to prove its identity
69+
3. **Client verifies the server's certificate**: The client validates the server's certificate against trusted Certificate Authorities (CAs)
70+
4. **Client presents its TLS certificate**: The client sends its own certificate to prove its identity
71+
5. **Server verifies the client's certificate**: The server validates the client's certificate
72+
6. **Server grants access**: Once both certificates are verified, the server allows the connection
7473
7. **Client and server exchange information over encrypted TLS connection**: All data is now transmitted securely
7574

7675
---
@@ -85,118 +84,27 @@ To enable mTLS in Cadence server, you need to configure TLS settings and start t
8584

8685
Use the `--zone` flag to specify the TLS configuration when starting the Cadence server:
8786

88-
```bash
87+
```shell
8988
./cadence-server --env development --zone tls start
9089
```
9190

92-
**Command breakdown:**
93-
- `--env development`: Specifies the environment configuration to use (corresponds to `config/development.yaml`)
94-
- `--zone tls`: Specifies the zone configuration to use (corresponds to the `tls` zone in `development_tls.yaml`)
95-
- `start`: Starts all Cadence services
96-
97-
The `--zone tls` flag tells the server to load additional configuration from the zone-specific file. In this case, it will look for `config/development_tls.yaml` which contains the TLS-specific settings.
98-
99-
#### TLS Configuration File
100-
101-
The server uses a YAML configuration file to define TLS settings. Here's an example from [`development_tls.yaml`](https://github.com/cadence-workflow/cadence/blob/master/config/development_tls.yaml):
102-
103-
```bash
104-
services:
105-
frontend:
106-
rpc:
107-
tls:
108-
enabled: true
109-
certFile: config/credentials/keytest.crt
110-
keyFile: config/credentials/keytest
111-
caFiles:
112-
- config/credentials/client.crt
113-
requireClientAuth: true
114-
115-
matching:
116-
rpc:
117-
tls:
118-
enabled: true
119-
certFile: config/credentials/keytest.crt
120-
keyFile: config/credentials/keytest
121-
122-
history:
123-
rpc:
124-
tls:
125-
enabled: true
126-
certFile: config/credentials/keytest.crt
127-
keyFile: config/credentials/keytest
128-
129-
clusterGroupMetadata:
130-
clusterGroup:
131-
cluster0:
132-
tls:
133-
enabled: true
134-
135-
```
91+
This will load [config/development.yaml](https://github.com/cadence-workflow/cadence/blob/master/config/development.yaml) \+ [config/development\_tls.yaml](https://github.com/cadence-workflow/cadence/blob/master/config/development_tls.yaml). See [CONTRIBUTING.md](https://github.com/cadence-workflow/cadence/blob/master/CONTRIBUTING.md#4-run) for more details.
92+
13693
---
13794

13895
### Client Implementation
13996

140-
To connect a Cadence client with mTLS, you need to configure TLS credentials and pass them to the Cadence client. Here's the essential code from the [helloworld_tls sample](https://github.com/cadence-workflow/cadence-samples/blob/master/new_samples/client_samples/helloworld_tls/hello_world_tls.go):
141-
142-
#### Setting up TLS Client Connection
143-
144-
```go
145-
import (
146-
"crypto/tls"
147-
"crypto/x509"
148-
"os"
149-
150-
"go.uber.org/cadence/client"
151-
"google.golang.org/grpc"
152-
"google.golang.org/grpc/credentials"
153-
)
154-
155-
func createCadenceClient() (client.Client, error) {
156-
// Load client certificate and key
157-
clientCert, err := tls.LoadX509KeyPair("credentials/client.crt", "credentials/client.key")
158-
if err != nil {
159-
return nil, err
160-
}
161-
162-
// Load CA certificate to verify server
163-
caCert, err := os.ReadFile("credentials/keytest.crt")
164-
if err != nil {
165-
return nil, err
166-
}
167-
168-
caCertPool := x509.NewCertPool()
169-
caCertPool.AppendCertsFromPEM(caCert)
170-
171-
// Configure TLS
172-
tlsConfig := &tls.Config{
173-
Certificates: []tls.Certificate{clientCert},
174-
RootCAs: caCertPool,
175-
ServerName: "cadence-frontend", // Must match server certificate CN
176-
}
177-
178-
// Create Cadence client with TLS
179-
return client.NewClient(client.Options{
180-
HostPort: "127.0.0.1:7833", // gRPC port
181-
Domain: "samples-domain",
182-
Transport: &client.TransportConfiguration{
183-
GRPCDialOptions: []grpc.DialOption{
184-
grpc.WithTransportCredentials(credentials.NewTLS(tlsConfig)),
185-
},
186-
},
187-
})
188-
}
189-
```
97+
To connect a Cadence client with mTLS, you need to configure TLS credentials and pass them to the Cadence client. Cadence client will use a gRPC transport object using your TLS settings to communicate with the server.
19098

19199
---
192100

193101
## Complete Working Example
194102

195-
The [helloworld_tls sample](https://github.com/cadence-workflow/cadence-samples/tree/master/new_samples/client_samples/helloworld_tls) provides a complete, tested implementation of mTLS with Cadence, including:
103+
The [helloworld\_tls sample](https://github.com/cadence-workflow/cadence-samples/tree/master/new_samples/client_samples/helloworld_tls) provides a complete, tested implementation of mTLS with Cadence, including:
196104

197-
- Certificate generation scripts
198-
- Complete client implementation with mTLS
199-
- Instructions for running with a TLS-enabled server
105+
- Certificate generation scripts
106+
- Complete client implementation with mTLS
107+
- Instructions for running with a TLS-enabled server
200108
- Step-by-step setup guide
201109

202110
For additional server configuration examples, refer to the [Cadence server repository](https://github.com/cadence-workflow/cadence)
@@ -208,7 +116,7 @@ For additional server configuration examples, refer to the [Cadence server repos
208116
The following table outlines various testing scenarios for mTLS configuration:
209117

210118
| Server | Client | Expected | Steps |
211-
|--------|--------|----------|-------|
119+
| :---- | :---- | :---- | :---- |
212120
| Unsecured | Unsecured | Success | Server without TLS enabled; Client without TLS certs |
213121
| Secured | Unsecured | Fail | Server with TLS enabled; Client without TLS certs |
214122
| Unsecured | Secured | Fail | Server without TLS enabled; Client **with** TLS certs |

0 commit comments

Comments
 (0)