我试图创建一个访问第三方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