所以我正在构建一个应用程序,我遇到了一个问题.我需要将JSON数据发布到https服务器.由于该应用程序目前正在开发中,因此我们使用自签名证书.
我怎样才能用dart语言实现这一目标?
下面是我用来通过http向Web服务器发送单个帖子请求的代码,但每当我用https(自签名)替换http时,我都会收到错误:
HandshakeException:客户端中的握手错误(操作系统错误:CERTIFICATE_VERIFY_FAILED:自签名证书(handshake.cc:355))
var url = 'http://192.168.1.40/registration.php'; //or https
var data = {"email":"yyyy@xx.com","name":"xyz"};
http.post(url, body:data)
.then((response) {
print("Response status: ${response.statusCode}");
print("Response body: ${response.body}");
}).catchError((error) => print(error.toString()));
Run Code Online (Sandbox Code Playgroud)
我对Flutter和Dart很新,请帮助我.建议将受到欢迎.