End-to-End Encryption (E2EE) - Flutter
Overview
End-to-end encryption (E2EE) ensures that your media content remains private and secure by encrypting it on the sender's device and decrypting it only on the receiver's device. This prevents intermediaries, including VideoSDK servers, from accessing or modifying the content.
E2EE is particularly important for applications in security-critical domains such as telehealth, finance, and legal services.
How E2EE Works
- E2EE is applied at the room level, where a single shared key encrypts and decrypts all media tracks during a session.
- Participants without the key cannot access the media.
- The entire encryption process is handled client-side. VideoSDK does not access or store any encryption keys.
Key Management & Distribution
You are fully responsible for generating, managing, and securely distributing encryption keys to all participants. VideoSDK never stores, accesses, or transfers your encryption keys.
- Common Key Distribution Approaches:
- Generate the key on your server when creating a meeting.
- Send the key securely along with the meeting access token.
- Use HTTPS-secured API calls to fetch the key on the client.
⚠️ Ensure that all participants have access to the correct encryption key before joining the room.
SDK Version Compatibility
The table below lists the minimum SDK versions that support E2EE.
Flutter | React | React Native | iOS | Android | JavaScript |
---|---|---|---|---|---|
2.1.0 | Coming Soon | Coming Soon | 2.2.2 | Coming Soon | Coming Soon |
Enabling E2EE in VideoSDK Flutter
To enable E2EE in Flutter, use the following setup:
@override
void initState() {
super.initState();
// Set up the encryption key
keySetup();
// Initialize the meeting instance
initMeeting();
}
Future<void> keySetup() async {
try {
var customKeyProvider = BaseKeyProvider();
await customKeyProvider.setSharedKey('<Your Encryption Key>');
VideoSDK.setKeyProvider(customKeyProvider);
} catch (e) {
print("Error setting encryption key: ${e.toString()}");
}
}
Additional Configuration Options
You can customize the encryption behavior by passing parameters while creating the BaseKeyProvider instance:
Parameter | Type | Description |
---|---|---|
discardFrameWhenCryptorNotReady | bool | If true , frames will be discarded when the cryptor is not ready, ensuring no unencrypted content is sent. |
Make sure to set the encryption key using setSharedKey
before assigning the key provider with setKeyProvider
, otherwise it will throw an error.
E2EE in Flutter Web
For Flutter Web, a dedicated worker file is required to handle cryptographic operations. Run the following command in your project root:
dart run videosdk:install_worker
This will install the required worker file inside your web directory.
Event for the e2ee state
To monitor encryption state changes for each participant's media stream:
widget.participant.on(Events.e2eeStateChanged, (
E2EEState state,
Stream stream,
) {
print("$state is for the ${stream.kind}");
});
The possible values for state
are:
State | Description |
---|---|
EncryptionSuccess | Media encryption is successfully applied. |
DecryptionSuccess | Incoming media is successfully decrypted. |
EncryptionFailed | Encryption encountered an error. |
DecryptionFailed | Decryption encountered an error. |
InternalError | Internal processing error occurred. |
To check whether E2EE is enabled
You can check whether E2EE is enabled by using e2eeEnabled
property of Room
class.
bool isE2EEEnabled = _room.e2eeEnabled;
print("Is E2EE Enabled: $isE2EEEnabled");
Limitations
E2EE only applies to media. It does not apply to:
- Chat messages or metadata
- API calls and signaling data
These communications are still protected by TLS but are not encrypted end-to-end.
Recording and transcription features are not supported when End-to-End Encryption (E2EE) is enabled.
Got a Question? Ask us on discord