gpt4 book ai didi

http - 将 https 与 flutter http.dart 包一起使用时出错

转载 作者:可可西里 更新时间:2023-11-01 16:20:12 25 4
gpt4 key购买 nike

我正在使用 http.dart 包来制作用于登录的 http post,当我在本地主机中使用(http 协议(protocol))的 restful api 时一切正常,但是当使用(https 协议(protocol))将我的后端 api 上传到共享主机时:

I/flutter (12071): HandshakeException: Handshake error in client (OS Error:
I/flutter (12071): CERTIFICATE_VERIFY_FAILED: unable to get local issuer certificate(handshake.cc:363))

这是我的http请求代码:

final res = await http
.post(Uri.encodeFull(url),
body: {"email": _user.text, "password": _pass.text},
headers: {'Accept' : 'application/json'});

这是所有的调试信息:

E/flutter (12071): [ERROR:flutter/shell/common/shell.cc(184)] Dart Error: Unhandled exception:
E/flutter (12071): HandshakeException: Handshake error in client (OS Error:
E/flutter (12071): CERTIFICATE_VERIFY_FAILED: unable to get local issuer certificate(handshake.cc:363))
E/flutter (12071): #0 IOClient.send (package:http/src/io_client.dart:33:23)
E/flutter (12071): <asynchronous suspension>
E/flutter (12071): #1 BaseClient._sendUnstreamed (package:http/src/base_client.dart:169:38)
E/flutter (12071): <asynchronous suspension>
E/flutter (12071): #2 BaseClient.post (package:http/src/base_client.dart:54:7)
E/flutter (12071): #3 post.<anonymous closure> (package:http/http.dart:70:16)
E/flutter (12071): #4 _withClient (package:http/http.dart:166:20)
E/flutter (12071): <asynchronous suspension>
E/flutter (12071): #5 post (package:http/http.dart:69:5)
E/flutter (12071): #6 LoginState._login (package:mis/auth/login.dart:41:23)
E/flutter (12071): <asynchronous suspension>
E/flutter (12071): #7 LoginState.build.<anonymous closure> (package:mis/auth/login.dart:216:31)
E/flutter (12071): #8 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:507:14)
E/flutter (12071): #9 _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:562:30)
E/flutter (12071): #10 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:102:24)
E/flutter (12071): #11 TapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:242:9)
E/flutter (12071): #12 TapGestureRecognizer.acceptGesture (package:flutter/src/gestures/tap.dart:204:7)
E/flutter (12071): #13 GestureArenaManager.sweep (package:flutter/src/gestures/arena.dart:156:27)
E/flutter (12071): #14 _WidgetsFlutterBinding&BindingBase&GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:184:20)
E/flutter (12071): #15 _WidgetsFlutterBinding&BindingBase&GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:158:22)
E/flutter (12071): #16 _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:138:7)
E/flutter (12071): #17 _WidgetsFlutterBinding&BindingBase&GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:101:7)
E/flutter (12071): #18 _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:85:7)
E/flutter (12071): #19 _invoke1 (dart:ui/hooks.dart:168:13)
E/flutter (12071): #20 _dispatchPointerDataPacket (dart:ui/hooks.dart:122:5)

最佳答案

根据 https://github.com/flutter/flutter/issues/27883

只需添加

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

在您应用的 android/app/src/main/AndroidManifest.xml

关于http - 将 https 与 flutter http.dart 包一起使用时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54728717/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com