Skip to content
This repository was archived by the owner on Oct 23, 2024. It is now read-only.

Commit f7de744

Browse files
authored
Merge pull request #1286 from qwu16/certificate
Add server pfx certificate and quic client token validation
2 parents 56ac232 + f468b86 commit f7de744

32 files changed

+1970
-230
lines changed
69.4 KB
Loading
11.4 KB
Loading
36.4 KB
Loading
24.9 KB
Loading
39.9 KB
Loading
44.7 KB
Loading
60.9 KB
Loading
87.8 KB
Loading
18.7 KB
Loading

doc/design/quic-cascading.md

Lines changed: 230 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,230 @@
1+
# OWT cascading design
2+
3+
## Overview
4+
5+
In real practice, users in a conference room may locate in different cities, countries, or continents. We can deploy one OWT cluster for the conference, and add different modules for each region as following diagram shows:
6+
![single cluster](./pics/cascading/oneclustermultiregions.png)
7+
8+
With this deployment, Rabbitmq will be in the cloud and other region-based modules will connect to cloud Rabbitmq service in the cloud. Rabbitmq will handle cross region rpc request and will introduce more unstable situations. And once the region network disconnects with cloud, modules in work-disconnected region cannot work independently. So, we consider using OWT cascading for the large and cross region deployment. Here is the overall view:
9+
![cascading clusters](./pics/cascading/overrall.png)
10+
11+
With this deployment, each region will deploy a separate OWT cluster. It’s easier for large deployment and the internal OWT cluster will work independently when region network disconnects with cloud. Here is a comparison for these 2 deployments:
12+
![comparison](./pics/cascading/comparison.png)
13+
14+
We will concentrate on OWT cascading design here.
15+
16+
## Cloud Management service
17+
18+
Cloud management service is deployed in a cloud for central management, it should implement following features:
19+
- Accept and record OWT cluster register info
20+
- Accept client request and assign OWT cluster to client
21+
- Record conference info and trigger OWT cluster cascading
22+
- Maintain OWT cluster info and conference info
23+
1 OWT cluster register
24+
OWT will register cluster info to cloud management service when the cluster is launched. This cluster registration work will be done in clusterManager. clusterManager will send the register requests to cloud after it gets service key/id info from management_api
25+
object(clusterInfo) {
26+
id: string, // name of the OWT cluster
27+
region: string, // region of the OWT cluster
28+
restfulip: string, // OWT restful server ip ?
29+
restfulport: string , //OWT restful server port ?
30+
eventbridgeip: string, // OWT event bridge listener ip
31+
eventbridgeport: string, // OWT event bridge listener port
32+
mediabridgeip: string, // OWT media bridge listener ip
33+
mediabridgeport: string //OWT media bridge listener port
34+
}
35+
OWT cluster manager will update capacity info to cloud if a new purpose agent joins the cluster or no such purpose agent lives in the cluster.
36+
Object (capacityinfo) {
37+
action: string, //actions: add, delete
38+
module: string //OWT modules: webrtc, streaming, video, audio…
39+
}
40+
OWT cluster manager will report room token to cloud for event/media bridge QUIC server to validate QUIC client connection. The token will be generated when room is initialized.
41+
object (tokeninfo) {
42+
room: string // conference room id
43+
token: string // conference room token
44+
}
45+
2 Handle client request
46+
Client will send a join conference request to cloud management service:
47+
Request body:
48+
type content
49+
json conferenceInfo
50+
object(conferenceInfo) {
51+
id: conferenceId,
52+
type: conferenceType
53+
}
54+
Response body:
55+
type content
56+
json clusterInfo
57+
object(clusterInfo) {
58+
ip: ip, //OWT cluster web server ip
59+
port: port, //OWT cluster web server port
60+
room: roomId //OWT cluster room id
61+
}
62+
3 Create room request
63+
Cloud management service will check saved conference info list to see if room has been created for this conference id in the owt cluster, if not, cloud management service will send create room request to owt cluster with room configuration according to client conference type, owt cluster will response with created room info.
64+
Users can define several conference templates which includes different room configurations, such as publication limit, SFU only. etc, so client can join specific kinds of room by specifying conference type. If no conference type is specified, then client will be assigned with the default room configuration template.
65+
object(conference) {
66+
id: conferenceId,
67+
cluster: [object(cluster)]
68+
}
69+
object(cluster) {
70+
id: clusterId,
71+
room: roomId
72+
}
73+
4 Trigger OWT cascading
74+
Here is the workflow for OWT cascading trigger:
75+
![trigger flow](./pics/cascading/triggerflow.png)
76+
In step 3, cloud management service will send a create room request with room configuration to ensure that different rooms in different OWT clusters serving for one conference will share the same room configuration. When getting a new client joining conference request and assigning owt cluster to client, cloud management service will trigger cascading if there are other OWT clusters in the same conferencing after getting the new client successfully joined room message from the assigned OWT cluster.
77+
If cascading is needed, cloud will send a request to owt1 to get the event/media bridge info, owt1 will schedule an event/media bridge and return related info to cloud:
78+
Request body:
79+
80+
type | content
81+
-------------|-----
82+
json|getBridgeInfo
83+
84+
85+
In real practice, the cascading trigger policy should be different based on different scenarios, users should customize this schedule policy in their deployment.
86+
Cascading request (from cloud management service to OWT cluster)
87+
Request body:
88+
89+
type | content
90+
---------|------
91+
json|cascading
92+
93+
object(cascading) {
94+
connectip: ip, //quic server ip address of owt cluster to connect
95+
connectport: port, // quic server port of owt cluster to connect
96+
room: roomId, // room id of owt cluster to connect
97+
}
98+
99+
![multi clusters](./pics/cascading/multicontrol.png)
100+
101+
## Event bridge
102+
103+
### Overall process
104+
105+
![event bridge process](./pics/cascading/eventbridgequic.png)
106+
For event cascading, each cluster will setup a quic session with another OWT, that means one quic session will represent one cascading connection between 2 OWT clusters. All the events in cluster rooms will be sent to another cluster through this quic session. Each conference in cascaded cluster will associate with a quic stream.
107+
Event bridge signaling process is listed:
108+
![event bridge flow](./pics/cascading/eventbridgeflow.png)
109+
For event bridge, the earlier joined cluster event bridge will work as quic server, and the later joined cluster event bridge will work as quic client and connect to previous joined cluster event bridge. Inside the OWT cluster, room id will be associated with related quic stream id, so every time when new data comes from quic stream, event bridge will check associated room id with this quic stream id and forward coming cascaded event data to specific conference node. Then the event cascading process between clusters will work properly.
110+
111+
### Forwarded events
112+
113+
Following event in conference will be forwarded to other OWT cluster when cascading establishes:
114+
115+
Type | description | Conference API
116+
-------------|--------------|--------------
117+
join|Participant join event|addParticipant
118+
leave|Participant leave event|removeParticipant
119+
add|Webrtc/quic forward stream added event|addStream
120+
add|Non-webrtc forward stream added event|addStream
121+
update|Stream info update event|updateStreamInfo
122+
remove|Remove stream event|removeStream
123+
update|Stream mute/unmute status update|setStreamMute
124+
initialize|Initialize stream and participant info to cascaded owt cluster|sonNewClusterCascaded
125+
126+
If owt cluster 2 successfully establishes QUIC connection with owt cluster 1, owt cluster 1 will send “initialize” event including all the room objects to owt cluster 2, then in owt cluster 2 event bridge, bridge will parse the message and simulate participant streams actions to owt cluster 2 conference node.
127+
Streams:
128+
QUIC client will create a bidirectional stream after successfully establishing QUIC connection with QUIC server. QUIC client will associate the created stream id with conference rpcId where startCascading event is from. QUIC client will then send the remote room info to server, server will bind the stream id with roomid retrieved from stream data.
129+
When a conference node in the cluster exits, event bridge will check the QUIC stream associated with it and terminate the stream.
130+
131+
## Media bridge
132+
133+
Overall process:
134+
![media bridge process](./pics/cascading/mediabridgequic.png)
135+
Media bridge will be used to transfer media streams between 2 OWT clusters. One QUIC connection will be established for each room in the cluster, and each OWT forward stream will be send through QUIC stream. For WebRTC stream, audio and video track of the same OWT forward stream will be sent out separately in different QUIC stream.
136+
Each media bridge node will be launched as QUIC server listening at the configured port. If the bridge gets a startCascading request, it will work as QUIC client and proactively establish QUIC connection with the QUIC server in another OWT cluster. A QUIC stream for signaling purpose will be created to exchange cluster info and make sure QUIC connection is ready to work for both sides. Here is a workflow for the initial QUIC connection establish process:
137+
![media bridge flow](./pics/cascading/mediabridgeflow.png)
138+
139+
## Build OWT server with cascading bridges
140+
141+
Because we don't have a good place to store pre-built QUIC SDK for public access, media/event bridge is not enabled by default. Additional flags are required to enable media/event bridge.
142+
1. Follow QUIC SDK ![build instruction](https://github.com/open-webrtc-toolkit/owt-sdk-quic/blob/main/quic_transport/docs/build_instructions.md) to generate the QUIC SDK library.
143+
2. Put ![headers](https://github.com/open-webrtc-toolkit/owt-sdk-quic/tree/main/quic_transport/sdk/api) to build/libdeps/build/include, and generated libraries(.so file) in above step to build/libdeps/build/lib.
144+
3. Append `-t quicCascading` to the arguments for build.js.
145+
4. Append `-t media-bridge/event-bridge` to the arguments for pack.js.
146+
147+
## How to configure cascading clusters
148+
149+
### Cloud control sample
150+
151+
We provide a simple cascading control sample in owt-server/source/cascading_sample folder, this is a reference sample for cascading control, in this sample, a simple web server will be launched to do following things:
152+
153+
API | Usage
154+
---------|------
155+
createConference|Create a conference ID
156+
createToken|Token used to validate participant
157+
registerCluster|OWT cluster register info to cloud control when cluster starts to work
158+
updateCapacity|OWT cluster update capacity (supported modules) to cloud control, this info can be used to do further scheduling according to cluster capacity
159+
updateConference|OWT cluster update conference token info to cloud control for quic client connection validation
160+
leaveConference|OWT cluster report conference leave info to cloud control when related conference room is destroyed
161+
unregisterCluster|OWT cluster unregister info to cloud control when cluster stops working
162+
163+
cloud control sample can be deployed on a separate environment when following steps:
164+
165+
```
166+
cd cascading_sample
167+
npm install
168+
node .
169+
170+
```
171+
172+
This is just a sample to show how cascading clusters control work, please customize your own scheduling and secured deployment in real practice.
173+
174+
### ClusterManager configuration
175+
176+
The OWT cluster will report cluster info to cloud control service through cluster_manager module in OWT, you need to configure following items in cascading item in cluster_manager/cluster_manager.toml file before starting it:
177+
178+
url: specify the cloud control url, so that cluster manager module can connect to the url and send cluster info
179+
region: specify the region this OWT cluster locate, this will be used by cloud control service to schedule incoming clients by region
180+
clusterID: specify a unique cluster ID for this cluster in the cloud.
181+
182+
### Media/event bridge
183+
184+
Configure QUIC server listen address or hostname with valid ip address or hostname in agent.toml in media_bridge and eventbridge folder, if self-signed certificate is used, please make sure address or hostname is added in leaf.cnf before generating self-signed certificate file. Specify certificate file location in `keystorePath`
185+
186+
````
187+
[bridge]
188+
# Key store path doesn't work right now.
189+
keystorePath = "./cert/certificate.pfx"
190+
191+
# ip address/hostname of QUIC server for media cascading is going to listen on.
192+
ip_address = '' #default: ""
193+
hostname = "" #default: ""
194+
195+
````
196+
197+
## Certificate for QUIC
198+
199+
OWT Conference Server is using a self-signed certificate during development phase, which would be only valid for 14 days. You can use a CA-signed certificate to avoid refreshing the certificate periodically. A CA-signed certificate is recommended for production environment. WebTransport connection will fail if certificate is not valid or expires.
200+
201+
### Certificates signed by a trusted CA
202+
203+
- Copy your PKCS12 format certificate to `media_bridge/cert/` and `eventbridge/cert/` directory to replace the one there.
204+
- Restart Conference Server media_bridge/eventbridge agent to apply the change.
205+
- Don't provide any fingerprint in client applications.
206+
207+
### Generate self-signed certificates
208+
209+
#### Precondition
210+
- Make sure you are running the tool under Linux and,
211+
- Openssl tool is correctly setup in your system.
212+
- Download the tool under chromium/src/net/tools/quic/certs/ from chromium project ([109.0.5414.67](https://chromium.googlesource.com/chromium/src/+archive/refs/tags/109.0.5414.67/net/tools/quic/certs.tar.gz.)) to local directory named `tool`. This contains three files: `ca.cnf`, `generate-certs.sh` and `leaf.cnf`.
213+
- Because WebTransport custom certificate verification doesn't support RSA, please modify the script to use ECDSA. You may refer to [this script](../../source/agent/addons/quic/test/scripts/generate-certs.sh) for testing.
214+
215+
#### Certificate Generation
216+
217+
- Modify leaf.cnf, adding an entry into `other_hosts` section.
218+
- Make sure generate-certs.sh is executable. If not, run `chmod +x generate-certs.sh`;
219+
- Remove the `out` dir in case it exists.
220+
- Under the downloaded tool dir, run `./generate-certs.sh`. It is expected to generate a series of files under out dir.
221+
- Under the downloaded tool dir, run `openssl pkcs12 -inkey out/leaf_cert.key -in out/leaf_cert.pem -export -out out/certificate.pfx`. This will prompt for password for the pfx. Please type the certificate password of your conference server. The default password is `abc123`.
222+
- Under the downloaded tool dir, run `openssl x509 -noout -fingerprint -sha256 -inform pem -in out/leaf_cert.pem`. You will get the fingerprint string in the form of "XX:XX:XX....XX:XX".
223+
224+
#### Use the Certificate
225+
226+
- Copy the generated certificate.pfx under `out` dir to `media_bridge/cert/` and `eventbridge/cert/` dir to replace the one there.
227+
- In the terminal environment where media_bridge/eventbridge agents run, make sure you export the fingerprint of new cert through variable `export QUIC_SERVER_FINGERPRINTS=XX:XX:XX....XX:XX`.
228+
- Restart Conference Server media_bridge/eventbridge agent to apply the change.
229+
230+

0 commit comments

Comments
 (0)