Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【TRTC_Flutter】将secretKey修改为SDKSecretKey #85

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions TRTC-API-Example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ This demo covers the following features (click to view the details of a feature)

You have [signed up](https://www.tencentcloud.com/) for a Tencent Cloud account and completed identity verification.

### Obtaining `SDKAPPID` and `SECRETKEY`
### Obtaining `SDKAPPID` and `SDKSECRETKEY`

1. Log in to the TRTC console and select **Application Management** > **[Create application](https://console.tencentcloud.com/trtc/app/create)**.
2. Click **Create Application** and enter the application name such as `APIExample`. If you have already created an application, click **Select Existing Application**.
Expand All @@ -58,13 +58,13 @@ You have [signed up](https://www.tencentcloud.com/) for a Tencent Cloud account
2. Set parameters in `GenerateTestUserSig.dart` as follows.

> - SDKAPPID: a placeholder by default. Set it to the actual `SDKAppID`.
> - SECRETKEY: a placeholder by default. Set it to the actual key.
> - SDKSECRETKEY: a placeholder by default. Set it to the actual key.
> ![#900px](https://imgcache.qq.com/operation/dianshi/other/flutter_sig.237b3ce20dde2fa6cac972f49169e7e539d691fd.png)

3. Click **Next** to complete the creation.
4. After compilation, click **Return to Overview Page**.

> !The method for generating `UserSig` described in this document involves configuring `SECRETKEY` in client code. In this method, `SECRETKEY` may be easily decompiled and reversed, and if your key is disclosed, attackers can steal your Tencent Cloud traffic. Therefore, **this method is suitable only for the local execution and debugging of the demo**.
> !The method for generating `UserSig` described in this document involves configuring `SDKSECRETKEY` in client code. In this method, `SDKSECRETKEY` may be easily decompiled and reversed, and if your key is disclosed, attackers can steal your Tencent Cloud traffic. Therefore, **this method is suitable only for the local execution and debugging of the demo**.

> The correct `UserSig` distribution method is to integrate the calculation code of `UserSig` into your server and provide an application-oriented API. When `UserSig` is needed, your application can make a request to the business server for dynamic `UserSig`. For more information, please see [How to Calculate UserSig](https://intl.cloud.tencent.com/document/product/647/35166).

Expand Down
6 changes: 3 additions & 3 deletions TRTC-API-Example/README_zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@

您已 [注册腾讯云](https://cloud.tencent.com/document/product/378/17985) 账号,并完成 [实名认证](https://cloud.tencent.com/document/product/378/3629)。

### 申请 SDKAPPID 和 SECRETKEY
### 申请 SDKAPPID 和 SDKSECRETKEY

1. 登录实时音视频控制台,选择【开发辅助】>【[快速跑通 Demo](https://console.cloud.tencent.com/trtc/quickstart)】。
2. 输入应用名称,例如`APIExample`;若您已创建过应用,可以勾选【选择已有应用】,然后单击【创建】。
Expand All @@ -60,13 +60,13 @@
2. 设置`GenerateTestUserSig.dart`文件中的相关参数:

> - SDKAPPID:默认为 PLACEHOLDER ,请设置为实际的 SDKAppID。
> - SECRETKEY:默认为 PLACEHOLDER ,请设置为实际的密钥信息。
> - SDKSECRETKEY:默认为 PLACEHOLDER ,请设置为实际的密钥信息。
> ![#900px](https://qcloudimg.tencent-cloud.cn/raw/c8a787f11cb3f52a49ffd04ad0197d4b.png)

3. 返回实时音视频控制台,单击【已复制粘贴,下一步】。
4. 单击【关闭指引,进入控制台管理应用】。

> !本文提到的生成 UserSig 的方案是在客户端代码中配置 SECRETKEY,该方法中 SECRETKEY 很容易被反编译逆向破解,一旦您的密钥泄露,攻击者就可以盗用您的腾讯云流量,因此**该方法仅适合本地跑通 Demo 和功能调试**。
> !本文提到的生成 UserSig 的方案是在客户端代码中配置 SDKSECRETKEY,该方法中 SDKSECRETKEY 很容易被反编译逆向破解,一旦您的密钥泄露,攻击者就可以盗用您的腾讯云流量,因此**该方法仅适合本地跑通 Demo 和功能调试**。

> 正确的 UserSig 签发方式是将 UserSig 的计算代码集成到您的服务端,并提供面向 App 的接口,在需要 UserSig 时由您的 App 向业务服务器发起请求获取动态 UserSig。更多详情请参见 [服务端生成 UserSig](https://cloud.tencent.com/document/product/647/17275#Server)。

Expand Down
6 changes: 3 additions & 3 deletions TRTC-API-Example/lib/Debug/GenerateTestUserSig.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/// Attention: do not use the code below in your commercial app. This is because:
///
/// The code may be able to calculate UserSig correctly, but it is only for quick testing of the SDK’s basic features, not for commercial apps.
/// `SECRETKEY` in client code can be easily decompiled and reversed, especially on web.
/// `SDKSECRETKEY` in client code can be easily decompiled and reversed, especially on web.
/// Once your key is disclosed, attackers will be able to steal your Tencent Cloud traffic.
///
/// The correct method is to deploy the `UserSig` calculation code and encryption key on your project server so that your app can request from your server a `UserSig` that is calculated whenever one is needed.
Expand Down Expand Up @@ -47,7 +47,7 @@ class GenerateTestUserSig {
* Note: this method is for testing only. Before commercial launch, please migrate the UserSig calculation code and key to your backend server to prevent key disclosure and traffic stealing.
* Reference: https://cloud.tencent.com/document/product/647/17275#Server
*/
static String secretKey = '';
static String sdkSecretKey = '';

/**
* CDN发布功能 混流appId
Expand Down Expand Up @@ -102,7 +102,7 @@ class GenerateTestUserSig {
int sdkappid = sdkAppId;
String contentToBeSigned =
"TLS.identifier:$identifier\nTLS.sdkappid:$sdkappid\nTLS.time:$currTime\nTLS.expire:$expire\n";
Hmac hmacSha256 = new Hmac(sha256, utf8.encode(secretKey));
Hmac hmacSha256 = new Hmac(sha256, utf8.encode(sdkSecretKey));
Digest hmacSha256Digest =
hmacSha256.convert(utf8.encode(contentToBeSigned));
return base64.encode(hmacSha256Digest.bytes);
Expand Down
4 changes: 2 additions & 2 deletions TRTC-Simple-Demo/README-zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@
3. 设置`GenerateTestUserSig.dart`文件中的相关参数:

> - SDKAPPID:默认为 PLACEHOLDER ,请设置为实际的 SDKAppID。
> - SECRETKEY:默认为 PLACEHOLDER ,请设置为实际的密钥信息。
> - SDKSECRETKEY:默认为 PLACEHOLDER ,请设置为实际的密钥信息。
> ![#900px](https://qcloudimg.tencent-cloud.cn/raw/c8a787f11cb3f52a49ffd04ad0197d4b.png)

4. 返回实时音视频控制台,单击【已复制粘贴,下一步】。
5. 单击【关闭指引,进入控制台管理应用】。

> 本文提到的生成 UserSig 的方案是在客户端代码中配置 SECRETKEY,该方法中 SECRETKEY 很容易被反编译逆向破解,一旦您的密钥泄露,攻击者就可以盗用您的腾讯云流量,因此**该方法仅适合本地跑通 Demo 和功能调试**。
> 本文提到的生成 UserSig 的方案是在客户端代码中配置 SDKSECRETKEY,该方法中 SDKSECRETKEY 很容易被反编译逆向破解,一旦您的密钥泄露,攻击者就可以盗用您的腾讯云流量,因此**该方法仅适合本地跑通 Demo 和功能调试**。

> 正确的 UserSig 签发方式是将 UserSig 的计算代码集成到您的服务端,并提供面向 App 的接口,在需要 UserSig 时由您的 App 向业务服务器发起请求获取动态 UserSig。更多详情请参见[服务端生成 UserSig](https://cloud.tencent.com/document/product/647/17275#Server)。

Expand Down
4 changes: 2 additions & 2 deletions TRTC-Simple-Demo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ You have [signed up](https://www.tencentcloud.com/) for a Tencent Cloud account
3. Set parameters in `GenerateTestUserSig.dart` as follows.

> - SDKAPPID: a placeholder by default. Set it to the actual `SDKAppID`.
> - SECRETKEY: a placeholder by default. Set it to the actual key.
> - SDKSECRETKEY: a placeholder by default. Set it to the actual key.
> ![#900px](https://imgcache.qq.com/operation/dianshi/other/flutter_sig.237b3ce20dde2fa6cac972f49169e7e539d691fd.png)

4. Click **Next** to complete the creation.
5. After compilation, click **Return to Overview Page**.

> The method for generating `UserSig` described in this document involves configuring `SECRETKEY` in client code. In this method, `SECRETKEY` may be easily decompiled and reversed, and if your key is leaked, attackers can steal your Tencent Cloud traffic. Therefore, **this method is only suitable for the local execution and debugging of the demo**.
> The method for generating `UserSig` described in this document involves configuring `SDKSECRETKEY` in client code. In this method, `SDKSECRETKEY` may be easily decompiled and reversed, and if your key is leaked, attackers can steal your Tencent Cloud traffic. Therefore, **this method is only suitable for the local execution and debugging of the demo**.

> The correct `UserSig` distribution method is to integrate the calculation code of `UserSig` into your server and provide an application-oriented API. When `UserSig` is needed, your application can send a request to the business server for a dynamic `UserSig`. For more information, please see [How do I calculate UserSig on the server?](https://intl.cloud.tencent.com/document/product/647/35166).

Expand Down
8 changes: 4 additions & 4 deletions TRTC-Simple-Demo/lib/debug/GenerateTestUserSig.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* Attention: do not use the code below in your commercial app. This is because:
*
* The code may be able to calculate UserSig correctly, but it is only for quick testing of the SDK’s basic features, not for commercial apps.
* `SECRETKEY` in client code can be easily decompiled and reversed, especially on web.
* `SDKSECRETKEY` in client code can be easily decompiled and reversed, especially on web.
* Once your key is disclosed, attackers will be able to steal your Tencent Cloud traffic.
*
* The correct method is to deploy the `UserSig` calculation code and encryption key on your project server so that your app can request from your server a `UserSig` that is calculated whenever one is needed.
Expand Down Expand Up @@ -49,12 +49,12 @@ class GenerateTestUserSig {
* Note: this method is for testing only. Before commercial launch, please migrate the UserSig calculation code and key to your backend server to prevent key disclosure and traffic stealing.
* Reference: https://cloud.tencent.com/document/product/647/17275#Server
*/
static String secretKey = '';
static String sdkSecretKey = '';

static genTestSig(String userId) {
if (kIsWeb) {
return JsGenerateTestUserSig()
.jsGenTestUserSig(sdkAppId, secretKey, userId, expireTime);
.jsGenTestUserSig(sdkAppId, sdkSecretKey, userId, expireTime);
}
int currTime = _getCurrentTime();
String sig = '';
Expand Down Expand Up @@ -90,7 +90,7 @@ class GenerateTestUserSig {
int sdkappid = sdkAppId;
String contentToBeSigned =
"TLS.identifier:$identifier\nTLS.sdkappid:$sdkappid\nTLS.time:$currTime\nTLS.expire:$expire\n";
Hmac hmacSha256 = new Hmac(sha256, utf8.encode(secretKey));
Hmac hmacSha256 = new Hmac(sha256, utf8.encode(sdkSecretKey));
Digest hmacSha256Digest =
hmacSha256.convert(utf8.encode(contentToBeSigned));
return base64.encode(hmacSha256Digest.bytes);
Expand Down
2 changes: 1 addition & 1 deletion TRTC-Simple-Demo/lib/debug/JsGenerateTestUserSig.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ class JsGenerateTestUserSig {
external JsGenerateTestUserSig();
external constructor();
// ignore: non_constant_identifier_names
external String jsGenTestUserSig(SDKAPPID, SECRETKEY, userID, expireTime);
external String jsGenTestUserSig(SDKAPPID, SDKSECRETKEY, userID, expireTime);
}
2 changes: 1 addition & 1 deletion TRTC-Simple-Demo/lib/ui/login.dart
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class LoginPageState extends State<LoginPage> {
MeetingTool.toast('Please fill in Sdkappid', context);
return;
}
if (GenerateTestUserSig.secretKey == '') {
if (GenerateTestUserSig.sdkSecretKey == '') {
MeetingTool.toast('Please fill in the key', context);
return;
}
Expand Down