Xamarin.Auth iOS9身份验证SSL错误 [英] Xamarin.Auth iOS9 Authentication SSL ERROR
问题描述
我刚刚将XCode更新为7.0(7A220),这使我的模拟器进入了iOS9.
I've just updated XCode to the 7.0 (7A220) and this take my Simulators to iOS9.
从那一刻起,我无法成功执行来自模拟器的任何OAUTH调用..我尝试了从我的应用程序到示例Xamarin.Auth应用程序"的每个模型.
From that moment I cannot perform successfully any OAUTH call from the simulators.. I tried every model, from my App to the "sample Xamarin.Auth App".
答案总是相同的:
身份验证错误
发生SSL错误,无法建立到服务器的安全连接"
An SSL error has occurred and a secure connection to the server cannot be made"
该代码是标准代码,我只更改了我的AppID. 相同的代码正在同一应用的Android版本上工作!
The Code is the STANDARD one, I only changed my AppID. The same code is working on the Android version of the same App!
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,同样的错误.可能是证书问题吗?
The IOS9 Simulator can surf the web, so it is not a "connectivity problem". I also tried with Facebook SDK, same error. Could it be a certificate issue?
谢谢
推荐答案
要解决此问题,只需将以下行添加到您的Info.plist文件中:
To Fix this problem, simply add to your Info.plist file these lines:
<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>
如果您不关心域的额外规则,只需添加:
If you don't care about extra rules for domains, you can simply add:
<key>NSAppTransportSecurity</key> <dict> <key>NSAllowsArbitraryLoads</key> <true/> </dict>
注意:您必须清理并重建项目,才能看到使用这些新设置运行的项目!
NOTE: you have to Clean and Rebuild the project in order to see it running with these new settings!
这篇关于Xamarin.Auth iOS9身份验证SSL错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!