我想NetworkImage在 Flutter 中加載一個,但由于以下原因無法使其作業:
Handshake error in client (OS Error:
CERTIFICATE_VERIFY_FAILED: unable to get local issuer certificate(handshake.cc:393))
不起作用(來自 Google Cloud Storage Cloud CDN 的影像)
NetworkImage("https://cdn.vaandra.com/items/f69f662f-41ff-4bb1-bd50-75a70b7ca6a5/439806b1-cacc-4d58-85a5-601bcb825fe3-p-500")
但是,這確實有效(來自 webz 的測驗影像)
NetworkImage("https://picsum.photos/250?image=9")
這是完整的錯誤訊息:
======== Exception caught by image resource service ================================================
The following HandshakeException was thrown resolving an image codec:
Handshake error in client (OS Error:
CERTIFICATE_VERIFY_FAILED: unable to get local issuer certificate(handshake.cc:393))
When the exception was thrown, this was the stack:
#0 _SecureFilterImpl._handshake (dart:io-patch/secure_socket_patch.dart:99:46)
#1 _SecureFilterImpl.handshake (dart:io-patch/secure_socket_patch.dart:142:25)
#2 _RawSecureSocket._secureHandshake (dart:io/secure_socket.dart:911:54)
#3 _RawSecureSocket._tryFilter (dart:io/secure_socket.dart:1040:19)
<asynchronous suspension>
Image provider: NetworkImage("https://cdn.vaandra.com/items/f69f662f-41ff-4bb1-bd50-75a70b7ca6a5/439806b1-cacc-4d58-85a5-601bcb825fe3-p-500", scale: 1.0)
Image key: NetworkImage("https://cdn.vaandra.com/items/f69f662f-41ff-4bb1-bd50-75a70b7ca6a5/439806b1-cacc-4d58-85a5-601bcb825fe3-p-500", scale: 1.0)
====================================================================================================
盡管該錯誤聲稱這是一個證書問題,但我無法理解它如何與同樣通過的公共影像一起作業https?
uj5u.com熱心網友回復:
創建一個擴展 http 覆寫的類
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());
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/490864.html
