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

1202: Android invalid certificate #1203

Merged
merged 4 commits into from
Nov 14, 2023
Merged
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
30 changes: 30 additions & 0 deletions frontend/assets/ca/lets-encrypt-r3.pem
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
-----BEGIN CERTIFICATE-----
MIIFFjCCAv6gAwIBAgIRAJErCErPDBinU/bWLiWnX1owDQYJKoZIhvcNAQELBQAw
TzELMAkGA1UEBhMCVVMxKTAnBgNVBAoTIEludGVybmV0IFNlY3VyaXR5IFJlc2Vh
cmNoIEdyb3VwMRUwEwYDVQQDEwxJU1JHIFJvb3QgWDEwHhcNMjAwOTA0MDAwMDAw
WhcNMjUwOTE1MTYwMDAwWjAyMQswCQYDVQQGEwJVUzEWMBQGA1UEChMNTGV0J3Mg
RW5jcnlwdDELMAkGA1UEAxMCUjMwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEK
AoIBAQC7AhUozPaglNMPEuyNVZLD+ILxmaZ6QoinXSaqtSu5xUyxr45r+XXIo9cP
R5QUVTVXjJ6oojkZ9YI8QqlObvU7wy7bjcCwXPNZOOftz2nwWgsbvsCUJCWH+jdx
sxPnHKzhm+/b5DtFUkWWqcFTzjTIUu61ru2P3mBw4qVUq7ZtDpelQDRrK9O8Zutm
NHz6a4uPVymZ+DAXXbpyb/uBxa3Shlg9F8fnCbvxK/eG3MHacV3URuPMrSXBiLxg
Z3Vms/EY96Jc5lP/Ooi2R6X/ExjqmAl3P51T+c8B5fWmcBcUr2Ok/5mzk53cU6cG
/kiFHaFpriV1uxPMUgP17VGhi9sVAgMBAAGjggEIMIIBBDAOBgNVHQ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
-----END CERTIFICATE-----
6 changes: 6 additions & 0 deletions frontend/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ PODS:
- connectivity_plus (0.0.1):
- Flutter
- ReachabilitySwift
- device_info_plus (0.0.1):
- Flutter
- fk_user_agent (2.0.0):
- Flutter
- Flutter (1.0.0)
Expand Down Expand Up @@ -99,6 +101,7 @@ PODS:

DEPENDENCIES:
- connectivity_plus (from `.symlinks/plugins/connectivity_plus/ios`)
- device_info_plus (from `.symlinks/plugins/device_info_plus/ios`)
- fk_user_agent (from `.symlinks/plugins/fk_user_agent/ios`)
- Flutter (from `Flutter`)
- flutter_secure_storage (from `.symlinks/plugins/flutter_secure_storage/ios`)
Expand Down Expand Up @@ -139,6 +142,8 @@ SPEC REPOS:
EXTERNAL SOURCES:
connectivity_plus:
:path: ".symlinks/plugins/connectivity_plus/ios"
device_info_plus:
:path: ".symlinks/plugins/device_info_plus/ios"
fk_user_agent:
:path: ".symlinks/plugins/fk_user_agent/ios"
Flutter:
Expand Down Expand Up @@ -166,6 +171,7 @@ EXTERNAL SOURCES:

SPEC CHECKSUMS:
connectivity_plus: 413a8857dd5d9f1c399a39130850d02fe0feaf7e
device_info_plus: c6fb39579d0f423935b0c9ce7ee2f44b71b9fce6
fk_user_agent: 1f47ec39291e8372b1d692b50084b0d54103c545
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
flutter_secure_storage: 23fc622d89d073675f2eaa109381aefbcf5a49be
Expand Down
7 changes: 6 additions & 1 deletion frontend/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
import 'dart:io';

import 'package:ehrenamtskarte/app.dart';
import 'package:ehrenamtskarte/build_config/build_config.dart';
import 'package:ehrenamtskarte/configuration/definitions.dart';
import 'package:ehrenamtskarte/l10n/translations.g.dart';
import 'package:ehrenamtskarte/sentry.dart';
import 'package:ehrenamtskarte/settings_provider.dart';
import 'package:ehrenamtskarte/util/android_certificate.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:slang/builder/model/enums.dart';

Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();

// support android version < 7.1.1 by adding a valid certificate - https://stackoverflow.com/questions/69511057
if (Platform.isAndroid && await certificateIsRequired()) {
loadCertificate();
}

// Only use device locale if set as available in build config, otherwise fallback to de
final locale = Platform.localeName.split('_')[0];
if (buildConfig.appLocales.contains(locale)) {
Expand Down
14 changes: 14 additions & 0 deletions frontend/lib/util/android_certificate.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import 'dart:io';
import 'package:flutter/services.dart';
import 'package:device_info_plus/device_info_plus.dart';

Future<void> loadCertificate() async {
ByteData? data = await PlatformAssetBundle().load('assets/ca/lets-encrypt-r3.pem');
SecurityContext.defaultContext.setTrustedCertificatesBytes(data.buffer.asUint8List());
}

Future<bool> certificateIsRequired() async {
DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();
AndroidDeviceInfo androidInfo = await deviceInfo.androidInfo;
return androidInfo.version.sdkInt < 25;
}
24 changes: 24 additions & 0 deletions frontend/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,22 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.7.8"
device_info_plus:
dependency: "direct main"
description:
name: device_info_plus
sha256: "7035152271ff67b072a211152846e9f1259cf1be41e34cd3e0b5463d2d6b8419"
url: "https://pub.dev"
source: hosted
version: "9.1.0"
device_info_plus_platform_interface:
dependency: transitive
description:
name: device_info_plus_platform_interface
sha256: d3b01d5868b50ae571cd1dc6e502fc94d956b665756180f7b16ead09e836fd64
url: "https://pub.dev"
source: hosted
version: "7.0.0"
df_build_config:
dependency: "direct dev"
description:
Expand Down Expand Up @@ -1468,6 +1484,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "4.1.4"
win32_registry:
dependency: transitive
description:
name: win32_registry
sha256: "1c52f994bdccb77103a6231ad4ea331a244dbcef5d1f37d8462f713143b0bfae"
url: "https://pub.dev"
source: hosted
version: "1.1.0"
xdg_directories:
dependency: transitive
description:
Expand Down
2 changes: 2 additions & 0 deletions frontend/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ environment:
dependencies:
flutter:
sdk: flutter
device_info_plus: "^9.1.0"
flutter_localizations:
sdk: flutter
intl: ^0.18.0
Expand Down Expand Up @@ -110,6 +111,7 @@ flutter:
- assets/nuernberg/background.png
- assets/nuernberg/intro_slides/
- assets/nuernberg/l10n/
- assets/ca/

# An image asset can refer to one or more resolution-specific 'variants', see
# https://flutter.dev/assets-and-images/#resolution-aware.
Expand Down