Facebook Xamarin.Auth iOS9身份验证SSL错误
我刚刚将XCode更新为7.0(7A220),这将把我的模拟器带到iOS9 从那一刻起,我无法成功执行来自模拟器的任何OAUTH调用。。我尝试了每种模式,从我的应用程序到“示例Xamarin.Auth应用程序” 答案总是一样的: “身份验证错误 发生SSL错误,无法与服务器建立安全连接“ 代码是标准的,我只更改了AppID。 相同的代码正在同一应用程序的Android版本上运行Facebook Xamarin.Auth iOS9身份验证SSL错误,facebook,xamarin,ios-simulator,ios9,xamarin.auth,Facebook,Xamarin,Ios Simulator,Ios9,Xamarin.auth,我刚刚将XCode更新为7.0(7A220),这将把我的模拟器带到iOS9 从那一刻起,我无法成功执行来自模拟器的任何OAUTH调用。。我尝试了每种模式,从我的应用程序到“示例Xamarin.Auth应用程序” 答案总是一样的: “身份验证错误 发生SSL错误,无法与服务器建立安全连接“ 代码是标准的,我只更改了AppID。 相同的代码正在同一应用程序的Android版本上运行 var auth = new OAuth2Authenticator ( clientId:
var auth = new OAuth2Authenticator (
clientId: "my app id",
scope: "",
authorizeUrl: new Uri ("https://m.facebook.com/dialog/oauth/"),
redirectUrl: new Uri ("http://www.facebook.com/connect/login_success.html"));
auth.AllowCancel = allowCancel;
// If authorization succeeds or is canceled, .Completed will be fired.
auth.Completed += (s, e) =>
{
// We presented the UI, so it's up to us to dismiss it.
dialog.DismissViewController (true, null);
if (!e.IsAuthenticated) {
facebookStatus.Caption = "Not authorized";
dialog.ReloadData();
return;
}
// Now that we're logged in, make a OAuth2 request to get the user's info.
var request = new OAuth2Request ("GET", new Uri ("https://graph.facebook.com/me"), null, e.Account);
request.GetResponseAsync().ContinueWith (t => {
if (t.IsFaulted)
facebookStatus.Caption = "Error: " + t.Exception.InnerException.Message;
else if (t.IsCanceled)
facebookStatus.Caption = "Canceled";
else
{
var obj = JsonValue.Parse (t.Result.GetResponseText());
facebookStatus.Caption = "Logged in as " + obj["name"];
}
dialog.ReloadData();
}, uiScheduler);
};
UIViewController vc = auth.GetUI ();
dialog.PresentViewController (vc, true, null);
IOS9模拟器可以在网上冲浪,因此它不是一个“连接问题”。我也尝试过Facebook SDK,同样的错误。可能是证书问题吗
感谢要解决此问题,只需在Info.plist文件中添加以下行:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>NSExceptionDomains</key>
<dict>
<key>facebook.com</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSExceptionRequiresForwardSecrecy</key>
<false/>
</dict>
<key>fbcdn.net</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSExceptionRequiresForwardSecrecy</key>
<false/>
</dict>
<key>akamaihd.net</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSExceptionRequiresForwardSecrecy</key>
<false/>
</dict>
</dict>
NSAppTransportSecurity
NSAllowsArbitraryLoads
NSExceptionDomains
facebook.com
n包括多个域
NSExceptionRequiresForwardSecretary
fbcdn.net
n包括多个域
NSExceptionRequiresForwardSecretary
akamaihd.net
n包括多个域
NSExceptionRequiresForwardSecretary
如果您不关心域的额外规则,只需添加:
<key>NSAppTransportSecurity</key> <dict> <key>NSAllowsArbitraryLoads</key> <true/> </dict>
NSAppTransportSecurity NSAllowsArbitraryLoads
注意:您必须清理并重建项目,才能看到它使用这些新设置运行 你的问题真是天赐良机!。我已经处理这个问题一整天了。您使用什么程序编辑info.plist文件?请更正第二段代码:NSAppTransportSecurity NSAllowsArbitraryLoads有人能解释一下此修复程序的作用吗?根本问题是什么?为什么添加。。呃。。这些额外的线路。。修好东西?哈利路亚:-)你救了这一天。谢谢你,我在我的Xamarin项目中疯了。