Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ssl/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ssl 关于颤振的gRPC自签名证书_Ssl_Flutter_Dart_Grpc_Self Signed - Fatal编程技术网

Ssl 关于颤振的gRPC自签名证书

Ssl 关于颤振的gRPC自签名证书,ssl,flutter,dart,grpc,self-signed,Ssl,Flutter,Dart,Grpc,Self Signed,我有一个Flitter应用程序,它使用gRPC与服务器通信。服务器正在为TLS使用自签名证书。我已经将证书添加到我的颤振应用程序中,这在Android上运行。但是,在iOS上,我获得证书\u验证\u失败错误。iOS不允许自签名证书吗 我正在设置我的gRPC客户端,如下所示: var cert = await rootBundle.load('assets/cert.crt'); var creds = ChannelCredentials.secure( cert

我有一个Flitter应用程序,它使用gRPC与服务器通信。服务器正在为TLS使用自签名证书。我已经将证书添加到我的颤振应用程序中,这在Android上运行。但是,在iOS上,我获得证书\u验证\u失败错误。iOS不允许自签名证书吗

我正在设置我的gRPC客户端,如下所示:

    var cert = await rootBundle.load('assets/cert.crt');
    var creds = ChannelCredentials.secure(
        certificates: cert.buffer.asUint8List().toList()
    );
    var channel = ClientChannel(
        host,
        port: port,
        options: new ChannelOptions(credentials: creds));
    return GrpcClient(channel);


在iOS上似乎没有一个明显的解决方案可以添加一个受信任的、自签名的根CA。因为生产可能会有一个公共受信任的CA,所以您可以通过禁用TLS验证来解决问题,仅用于开发

以下是我的演讲的相关片段:

Future makeChannel()异步{
final caCert=wait rootBundle.loadString('assets/pki/ca/ca.crt');
返回客户端通道(
'本地主机',
港口:13100,
选项:频道选项(
凭据:ChannelCredentials.secure(
证书:utf8.encode(caCert),
//---自签名开发CA的解决方案---
onBadCertificate:(证书,主机)=>host='localhost:13100',
),
),
);
}

在这种情况下,我的服务器正在监听
localhost:13100

谢谢,这基本上就是我最后所做的。嘿@AndiDog,我的应用程序的行为会有所不同,这取决于我是否添加
onBadCertificate
,如果没有它,我会得到:
CERTIFICATE\u VERIFY\u失败:无法获得本地颁发者证书
,并且使用它,我得到:
SSLV3\u警报\u坏的\u证书
…都是相同的
.perm
文件…有什么线索可能出错吗?在Wireshark或日志中调试警报?既然您看到了差异,我假设所需的效果确实有效,但您可能由于其他原因(例如,坏的客户端证书)仍然收到服务器端警报。@JamesTan No.但是哪个flifter平台运行节点?您是否将服务器端Dart代码交叉编译到node.js?那也许会有帮助。对不起,我用的是nodejs作为客户端,而不是flutter。我还没有尝试过这个参考,但我做到了: