Xamarin android OAuth与ADFS和ADAL问题

问题描述 投票:0回答:1

我正在编写一个使用ADAL进行身份验证的Xamarin.Forms应用程序。我目前正在关注此流程。

https://forums.xamarin.com/discussion/comment/367489#Comment_367489

我正在使用ADFS进行身份验证,我现在只担心Android客户端。我的问题是,每当我调用AcquireTokenAsync时,我都会获得登录屏幕但没有内容。

enter image description here

我已经证明使用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; 

任何有关这方面的帮助都会非常感激,我真的一直在反对它几天。

android xamarin xamarin.forms adfs adal
1个回答
0
投票

基于您的错误,java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.此问题与您的证书相关,您的设备不信任您的证书,您可以检查Android设备中的可信凭据,它是否包含您的根证书和中间证书?您基本上有四种可能的解决方案来使用httpclient修复Android上的“不受信任”异常:

  1. 信任所有证书。不要这样做,除非你真的知道你在做什么。
  2. 创建仅信任您的证书的自定义SSLSocketFactory。只要您确切知道要连接到哪些服务器,这就行,但只要您需要连接到具有不同SSL证书的新服务器,您就需要更新您的应用程序。
  3. 创建一个包含Android的证书“主列表”的密钥库文件,然后添加自己的。如果这些证书中的任何一个到期,您有责任在您的应​​用程序中更新它们。我想不出这样做的理由。
  4. 创建一个使用内置证书KeyStore的自定义SSLSocketFactory,但是对于无法使用默认值验证的任何内容,可以使用备用KeyStore。

你可以参考这个类似的线程。 Trusting all certificates using HttpClient over HTTPS

© www.soinside.com 2019 - 2024. All rights reserved.