checkIsConnectionSecure method

  1. @override
Future<void> checkIsConnectionSecure({
  1. required String serverUrl,
  2. required SHA sha,
  3. int timeout = 60,
  4. required List<String> allowedSHAFingerprints,
})
override

Implementation

@override
Future<void> checkIsConnectionSecure({
  required String serverUrl,
  required SHA sha,
  int timeout = 60,
  required List<String> allowedSHAFingerprints,
}) async {
  try {
    final connection = await HttpCertificatePinning.check(
      serverURL: serverUrl,
      sha: sha,
      allowedSHAFingerprints: allowedSHAFingerprints,
      timeout: timeout,
    );
    if (!connection.contains('CONNECTION_SECURE')) {
      throw FeatureNetworkException(
        code: 'CONNECTION_NOT_SECURE',
        message: 'Connection not secure: $connection',
      );
    }
  } on PlatformException catch (e) {
    throw FeatureNetworkException(
      code: 'BAD_CERTIFICATE',
      message: 'Bad Certificate: $e',
    );
  }
}