服务器正常运行,并通过回显客户端进行了测试。
使用以下命令运行我的应用程序时全部正常
final channel = IOWebSocketChannel.connect("wss://hostname:port");
channel.sink.add('test');
channel.stream.listen((message) {
debugPrint(message);
channel.sink.close(status.goingAway);
此重复出现的消息的调试控制台异常:
E/flutter (19705): [ERROR:flutter/lib/ui/ui_dart_state.cc(166)] Unhandled Exception: WebSocketChannelException: WebSocketChannelException: HandshakeException: Handshake error in client (OS Error:
E/flutter (19705): CERTIFICATE_VERIFY_FAILED: unable to get local issuer certificate(handshake.cc:354))
我通过多种方式尝试使我的颤抖应用程序信任Let's Encrypt CA,但没有成功。
对于解决我的问题的任何回应将不胜感激!
答案 0 :(得分:0)
好的,我一周前解决了它,却忘记发布答案了。 这更像是一种解决方法,但仍然稳定... 我使用了一个apache2网络服务器,该服务器使用反向代理到websocket服务器。 现在apache服务器已经安装了证书,我在openssl上使用s_client来检查浏览器/客户端是否接受证书,这是在我将apache2用作反向代理之后所做的。
答案 1 :(得分:0)
class MyHttpOverrides extends HttpOverrides {
@override
HttpClient createHttpClient(SecurityContext context) {
return super.createHttpClient(context)
..badCertificateCallback =
(X509Certificate cert, String host, int port) => true;
}
}
void main() {
HttpOverrides.global = new MyHttpOverrides();
runApp(MyApp());
}