簡體   English   中英

Flutter Virgil E3 套件不在發布模式下工作,但在調試下工作

[英]Flutter Virgil E3 Kit not working in release mode but working in debug

我正在嘗試將 Virgil e3 Kit 實施到我的 flutter 應用程序中以進行端到端加密。 運行代碼並在調試模式下注冊時,Ethree Kit 運行良好,但是當我嘗試在發布模式下運行時,在使用 EThree Kit 注冊用戶時出現異常。

這是 package: https://github.com/cardoso/virgil-e3kit-flutter

這是錯誤: Failed to register user for encryption system: PlatformException(unknown_error, Http response: 400: Bad Request Service response: 40200: Identity search parameter cannot be empty., null, null)

我認為這與明文流量有關,所以我在我的 androidManifest 中啟用了它,但它仍然不起作用

這是我正在調用的代碼:

注冊

final firebaseUser = await _firebaseAuth.createUserWithEmailAndPassword(
      email: email, password: password);

  await EncryptionUtils.initialize(_firebaseAuth.currentUser.uid);
  await EncryptionUtils.register();
  await EncryptionUtils.backupPrivateKey(
      '${_firebaseAuth.currentUser.uid}...$password');

初始化

static Future<void> initialize(String uid) async {
if (_eThree != null) return;

final tokenCallback = () async {
  final response = (await FirebaseFunctions.instance
          .httpsCallable('getVirgilJwt')
          .call())
      .data;

  final Map<String, dynamic> data = Map<String, dynamic>.from(response);
  print('[encryption tokenCallback] - ${data['token']}');
  return data['token'];
};

try {
  if (uid == null || uid.isEmpty) {
    throw Exception('user-id not valid');
  }

  _eThree = await EThree.init(uid, tokenCallback);
  print('[ENCRYPTION UTILS] - (initialize) initialized successfully');
} catch (err) {
  print('[ENCRYPTION UTILS] - Failed initializing: $err');
  throw Exception('Failed to intialize end to end encryption system');
}
}

登記

static Future<void> register() async {
try {
  await _eThree.cleanUp();
  print('[ENCRYPTION UTILS] - (Register) cleaned up successfully');
} catch (err) {
  print('[ENCRYPTION UTILS] - (Register) failed to cleanup');
}

try {
  print(
      '[encryption register] - trying to register ${await _eThree.identity}');
  
  await _eThree.register();
  print('[ENCRYPTION UTILS] - registered successfully');
} on PlatformException catch (err) {
  if (err.code == 'user_is_already_registered') {
    await _eThree.rotatePrivateKey();
    print('Rotated private key instead');
  }
  print('Failed to register user for encryption system: $err');
  throw Exception('Failed to register user for encryption system: $err');
}
}

先感謝您!

我知道這是一個老問題,但我遇到了同樣的問題並想分享我的解決方案。 我在 Android 應用程序的 build.gradle 文件中添加了以下行,以防止包大小優化。 您可以在 Virgil Android SDK 示例應用程序中找到相同的配置。

buildTypes {
    release {
        ...
        minifyEnabled false
        shrinkResources false
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM