From 8300fc8ca92d605866fb9f9edd3fb8e650ac0343 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Wed, 15 Apr 2020 11:13:39 +0200 Subject: [PATCH] Fix HTTPs issue --- lib/main_dev.dart | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lib/main_dev.dart b/lib/main_dev.dart index 5771a74..5d39cfa 100644 --- a/lib/main_dev.dart +++ b/lib/main_dev.dart @@ -1,3 +1,5 @@ +import 'dart:io'; + import 'package:comunic/main.dart'; import 'package:comunic/models/config.dart'; @@ -5,6 +7,17 @@ import 'package:comunic/models/config.dart'; /// /// @author Pierre HUBERT +/// Fix HTTPS issue +class MyHttpOverride extends HttpOverrides { + @override + HttpClient createHttpClient(SecurityContext context) { + return super.createHttpClient(context) + ..badCertificateCallback = (cert, host, port) { + return host == "devweb.local"; // Forcefully trust local website + }; + } +} + void main() { Config.set(Config( apiServerName: "192.168.1.9:3000", @@ -15,5 +28,7 @@ void main() { termsOfServicesURL: "http://devweb.local/comunic/current/about.php?cgu", )); + HttpOverrides.global = new MyHttpOverride(); + subMain(); }