Advertisement

Responsive Advertisement

Flutter Error Solved - OS Error: CERTIFICATE_VERIFY_FAILED: unable to get local issuer certificate

 


ini terjadi di Flutter 2.10
Jika ketemu error ini lagi. ingat solusi ini Maliiiiik !
Sehari semalam baru solved

kayak gini error nya :

Exception has occurred.
HandshakeException (HandshakeException: Handshake error in client (OS Error: CERTIFICATE_VERIFY_FAILED: unable to get local issuer certificate(handshake.cc:393)


ATAU
KAYA GINI ERROR NYA :

SOLUSI NYA :

1. Tambahkan ini di MAIN.DART
tepatnya diatasnya class utamanya

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

2. Pasang ini di Service nya atau tempat kamu gunain http nya

    HttpOverrides.global = MyHttpOverrides();

contoh lengkapnya kaya gini

getArticleData(apiUrl) async {
HttpOverrides.global = MyHttpOverrides();
http.Response response = await http.get(Uri.parse(_url + apiUrl));

try {
if (response.statusCode == 200) {
return response;
} else {
return 'failed';
}
} catch (e) {
print(e);
return 'failed';
}
}

3. Pastikan Permission internetnya digunakan

<uses-permission android:name="android.permission.INTERNET" />

biasanya letaknya disini android/app/src/main/AndroidManifest.xml

contohnya :

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.belajar_terus">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:label="belajar_terus"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher">
<activity




Posting Komentar

0 Komentar