-1

I am using the http pacckage with Flutter and am running my rest server locally for testing purposes. A year or so ago this worked, but now I think I need to have an SSL certificate even for testing.

I've tried a couple of step by steps using openssl, but both failed. One created the pem but not the cert file.

Is there any good step by step instructions on how to create an SSL cert for local host that I can use for Flutter development with http.

And do I need to use a certain ip address with it?

Or is this not needed and is there a better way to do this?

Patrick Mevzek
  • 10,995
  • 16
  • 38
  • 54
Paul Coshott
  • 735
  • 1
  • 9
  • 16

1 Answers1

0

create a class like so

import 'dart:io';

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

and then in the main function usually in main.dart in the lib folder add this line to instantiate your class

HttpOverrides.global = new MyHttpOverrides();

this issue has been dealt with check out :

for more info about the bad certificate validation