Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Ability to use self signed cert #84

Closed
lehno opened this issue Apr 30, 2020 · 6 comments
Closed

Ability to use self signed cert #84

lehno opened this issue Apr 30, 2020 · 6 comments

Comments

@lehno
Copy link

lehno commented Apr 30, 2020

I would like to have the option rejectUnauthorized like web. It helps for developing using https localhost

@jumperchen
Copy link
Member

FYI: dart-lang/sdk#34284
It may not be this library problem.

@lehno
Copy link
Author

lehno commented May 7, 2020

Socket.io for web has this options, it would be good to have it here as well.
For now the fix is this:

class MyHttpOverrides extends HttpOverrides {
  @override
  HttpClient createHttpClient(SecurityContext context) {
    return super.createHttpClient(context)
      ..badCertificateCallback =
          (X509Certificate cert, String host, int port) => true;
  }
}

void main() {
  HttpOverrides.global = new MyHttpOverrides();
  runApp(MyApp());
}

@kbrmimbyl
Copy link

@lehno you just saved me a ton of pain, thanks!

@cobategit
Copy link

Socket.io for web has this options, it would be good to have it here as well.
For now the fix is this:

class MyHttpOverrides extends HttpOverrides {
  @override
  HttpClient createHttpClient(SecurityContext context) {
    return super.createHttpClient(context)
      ..badCertificateCallback =
          (X509Certificate cert, String host, int port) => true;
  }
}

void main() {
  HttpOverrides.global = new MyHttpOverrides();
  runApp(MyApp());
}

i get error in "createHttpClient", anyone solve this ?,.
thanks

@ElsayedDev
Copy link
Contributor

Socket.io for web has this options, it would be good to have it here as well.
For now the fix is this:

class MyHttpOverrides extends HttpOverrides {
  @override
  HttpClient createHttpClient(SecurityContext context) {
    return super.createHttpClient(context)
      ..badCertificateCallback =
          (X509Certificate cert, String host, int port) => true;
  }
}

void main() {
  HttpOverrides.global = new MyHttpOverrides();
  runApp(MyApp());
}

i get error in "createHttpClient", anyone solve this ?,. thanks

Just change SecurityContext to SecurityContext? and it will work

@Mumunt
Copy link

Mumunt commented Apr 20, 2022

this solution need to import dart.io

but how about flutter web?

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants