flutter network_error ai_generated partial

HandshakeException:客户端握手错误(操作系统错误:CERTIFICATE_VERIFY_FAILED: ok(handshake.cc:393))

HandshakeException: Handshake error in client (OS Error: CERTIFICATE_VERIFY_FAILED: ok(handshake.cc:393))

ID: flutter/dart-io-ssl-handshake-error

其他格式: JSON · Markdown 中文 · English
75%修复率
85%置信度
1证据数
2023-06-01首次发现

版本兼容性

版本状态引入弃用备注
Flutter 3.10 active
Dart 3.0 active
iOS 16 active
Android 13 active

根因分析

SSL 证书验证失败,通常由自签名证书、证书过期或设备信任存储中缺少中间 CA 导致。

English

SSL certificate verification failed, typically due to a self-signed certificate, expired certificate, or missing intermediate CA in the device's trust store.

generic

官方文档

https://api.flutter.dev/flutter/dart-io/HttpClient-class.html

解决方案

  1. Add the self-signed certificate to the device's trust store, or use a proper CA-signed certificate on the server.
  2. If testing only, use a custom HttpClient with badCertificateCallback that validates the specific certificate fingerprint.

无效尝试

常见但无效的做法:

  1. 80% 失败

    Disables all certificate validation, creating a security vulnerability and may still fail on some platforms due to other TLS checks.

  2. 90% 失败

    The underlying SSL issue persists; retrying without fixing the certificate chain will produce the same error.

  3. 70% 失败

    The http package also relies on dart:io's underlying TLS implementation; the error will be identical.