CERTIFICATE_VERIFY_FAILED flutter
1,915
I got the solution :)
You need to add the following line in your class's constructor that extends the GetConnect
allowAutoSignedCert = true;
Author by
che4len
Updated on January 03, 2023Comments
-
che4len over 1 year
Encountered an error when sending a post request. A local server with a self-signed certificate is used as the server. An https connection is also used.
To connect I use
GetConnect
which is included in the getX packageThis error appears:
HandshakeException: Handshake error in client (OS Error: CERTIFICATE_VERIFY_FAILED: unable to get local issuer certificate(handshake.cc:393))
I tried to allow the use of self-signed certificates with the following code, but it didn't help me:
class MyHttpOverrides extends HttpOverrides { @override HttpClient createHttpClient(SecurityContext context) { return super.createHttpClient(context) ..badCertificateCallback = (X509Certificate cert, String host, int port) => true; } }
Also in the main function I specified the following line:
HttpOverrides.global = MyHttpOverrides();