我正在编写一个使用ADAL进行身份验证的Xamarin.Forms应用程序。我目前正在关注此流程。
https://forums.xamarin.com/discussion/comment/367489#Comment_367489
我正在使用ADFS进行身份验证,我现在只担心Android客户端。我的问题是,每当我调用AcquireTokenAsync时,我都会获得登录屏幕但没有内容。
我已经证明使用postman从ADFS获取令牌并且没有任何问题。
我的代码(我现在只是试图证明这一点,我真的不关心实现):
string authority = "https://myserver/adfs";
string resourceURI = "myidentity";
string clientID = "123-123-123";
string clientReturnURI = "http://localhost/";
var authContext = new AuthenticationContext(authority,false);
Task.Run(async () =>
{
var authResultAsync = await authContext.AcquireTokenAsync(resourceURI, clientID, new Uri(clientReturnURI), PlatformParameters);
});
我的平台参数正在pagerenderer中设置
protected override void OnElementChanged(ElementChangedEventArgs<Page> e)
{
base.OnElementChanged(e);
this.page = e.NewElement as MainPage;
this.page.PlatformParameters = new PlatformParameters(this.Context as Activity);
}
我唯一的领导是我在我的控制台输出中得到这个
Failed to validate the certificate chain, error: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
我也得到了这个,但它似乎是一个红色的鲱鱼(一些博客文章说只是在Android N设备上显示我正在使用的sdk级别)
Rejecting re-init on previously-failed class java.lang.Class<uO>: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/webkit/TracingController;
任何有关这方面的帮助都会非常感激,我真的一直在反对它几天。
基于您的错误,java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
此问题与您的证书相关,您的设备不信任您的证书,您可以检查Android设备中的可信凭据,它是否包含您的根证书和中间证书?您基本上有四种可能的解决方案来使用httpclient修复Android上的“不受信任”异常:
你可以参考这个类似的线程。 Trusting all certificates using HttpClient over HTTPS