A simple example for how to use private key and certificate in you flutter app with a server example https://github.com/rodnt/flask-mtls
- Download flutter enviroment: https://flutter-ko.dev/get-started/install
- Configure the mtls server at https://github.com/rodnt/flask-mtls
- Copy ca.crt,certificate.crt and private.key generated from flask-mtls to anyplace that you want.
- Add to EXPORT env at terminal (iterm2, Terminator.. etc..)
# b 0 from macOS and w 0 from linux
export PRIVATE_KEY_BASE64="$(base64 -b 0 assets/keys/private.key)"; export CERTIFICATE_BASE64="$(base64 -b 0 assets/keys/certificate.crt)"
- Inside the project run the following command
flutter run --release --dart-define=PRIVATE_KEY_BASE64=$PRIVATE_KEY_BASE64 --dart-define=CERTIFICATE_BASE64=$CERTIFICATE_BASE64
-
Test the app :)
-
You can get the APK at
mtls_example_flutter/build/app/outputs/flutter-apk/