简体   繁体   中英

Flutter on android CERTIFICATE_VERIFY_FAILED: certificate has expired

Only on flutter in android all calls to my server throw the following error CERTIFICATE_VERIFY_FAILED: certificate has expired(handshake.cc:359))

From the mobile browser my site works, from the PC browser also, and also from the flutter web. Only from android it says certificate expired.

I have checked with SSL Checker and everything is setup correctly. Output of SSL Checker:

$MYDOMAIN resolves to $MYIP
    
Server Type: Caddy
    
The certificate should be trusted by all major web browsers (all the correct intermediate certificates are installed).
    
The certificate was issued by Let's Encrypt.
    
The certificate will expire in 79 days.     
    
The hostname ($MYDOMAIN) is correctly listed in the certificate.

Does anybody know how to fix this?

just 2 step need for fix error

1.create cutom class extended

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

2.add line to main function

HttpOverrides.global = CustomHttpOverrides();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM