我試圖創建一個訪問第三方API的代理服務器,但他們的開發結束點有證書錯誤。無論如何,使用http.dart時繞過ssl錯誤?使用http繞過證書錯誤
import 'package:http/http.dart' as http;
Uri url = Uri.parse("https://url-with-ssl-error.com/endpoint");
http.get(url).then((response) => print(response.body));
,這裏是返回的錯誤:「對等的證書頒發者已被標記爲未受到用戶信任」
Uncaught Error: SocketIOException: RawSecureSocket error (Unexpected handshake error in client) (OS Error: errno = -8172)
Unhandled exception:
SocketIOException: RawSecureSocket error (Unexpected handshake error in client) (OS Error: errno = -8172)
#0 _FutureImpl._scheduleUnhandledError.<anonymous closure> (dart:async/future_impl.dart:207:9)
#1 Timer.run.<anonymous closure> (dart:async/timer.dart:17:21)
#2 Timer.run.<anonymous closure> (dart:async/timer.dart:25:13)
#3 Timer.Timer.<anonymous closure> (dart:async-patch:15:15)
#4 _Timer._createTimerHandler._handleTimeout (dart:io:6990:28)
#5 _Timer._createTimerHandler._handleTimeout (dart:io:6998:7)
#6 _Timer._createTimerHandler.<anonymous closure> (dart:io:7006:23)
#7 _ReceivePortImpl._handleMessage (dart:isolate-patch:81:92)
你能展示代碼的相關部分和確切的錯誤嗎? – 2013-05-13 14:35:23
@ZdeslavVojkovic我用代碼編輯我的問題,並返回錯誤 – 2013-05-13 15:34:58
嘗試在get之前添加'SecureSocket.initialize()'。請參閱http://stackoverflow.com/questions/13964492/socketioexception-unexpected-handshake-error-in-client和http://code.google.com/p/dart/issues/detail?id=7541 – 2013-05-13 15:40:40