【问题标题】:ServiceStack Facebook Authentication NullReference Exception on Vagrant Box (Ubuntu/MySql/Mono/nginx)Vagrant Box (Ubuntu/MySql/Mono/nginx) 上的 ServiceStack Facebook 身份验证 NullReference 异常
【发布时间】:2013-07-31 08:15:57
【问题描述】:

我猜是远射,因为我在这个阶段提供的真实信息缺乏。我很乐意提供有关如何重现该问题的更多详细信息 - 但希望获得一些快速反馈,以查看我是否遗漏了 gotcha

我有一个简单的 ServiceStack hello world 应用程序,我在其中使用 Facebook Auth Provider:

  • 原版服务堆栈
  • 原版 Facebook 身份验证提供程序
  • 原版用户会话
  • Vanilla OrmLite 用户存储库
  • 香草 OrmLite MySql Db 工厂

在我的本地机器上调试时 - 在 Windows 7(和 8)上;一切都是一种享受。服务启动,创建数据库表,我可以通过 Facebook 登录并将记录插入到相关表中。

在 Vagrant Box 内的 Ubuntu 上运行服务时(在 Virtual Box 中作为虚拟化提供者运行,使用 mono-fastcgi 托管在 nginx 上) - 服务正确启动,我可以看到表是在 MySql 数据库中创建的.当我点击/auth/facebook 时,我正确转发到了 Facebook - 但是在发生对服务的回调时我遇到了错误。

这是当前的输出:

[Auth: 07/30/2013 13:02:47]: [REQUEST: {provider:facebook}] System.NullReferenceException: Object reference not set to an instance of an object at 
ServiceStack.ServiceInterface.Auth.FacebookAuthProvider.Authenticate (ServiceStack.ServiceInterface.IServiceBase,ServiceStack.ServiceInterface.Auth.IAuthSession,ServiceStack.ServiceInterface.Auth.Auth) <0x0061e> at 
ServiceStack.ServiceInterface.Auth.AuthService.Authenticate (ServiceStack.ServiceInterface.Auth.Auth,string,ServiceStack.ServiceInterface.Auth.IAuthSession,ServiceStack.ServiceInterface.Auth.IAuthProvider) <0x000a7> at 
ServiceStack.ServiceInterface.Auth.AuthService.Post (ServiceStack.ServiceInterface.Auth.Auth) <0x00303> at 
ServiceStack.ServiceInterface.Auth.AuthService.Get (ServiceStack.ServiceInterface.Auth.Auth) <0x00013> at (wrapper dynamic-method) object.lambda_method (System.Runtime.CompilerServices.Closure,object,object) <0x0004f> at 
ServiceStack.ServiceHost.ServiceRunner`1<ServiceStack.ServiceInterface.Auth.Auth>.Execute (ServiceStack.ServiceHost.IRequestContext,object,ServiceStack.ServiceInterface.Auth.Auth) <0x00416>

它显然正在访问服务(我通过localhost:8080 访问它,它映射到端口 80 上的客户机);因为错误很好地包含在 ServiceStack 输出中。

我想没有人有任何线索吗?

【问题讨论】:

    标签: servicestack


    【解决方案1】:

    经过一晚上的调查后,我找到了根本原因。

    Line 51 of FacebookAuthProvider.cs 调用 Line 28 of WebRequestExtensions.cs - 而后者又调用 Line 227 of WebRequestExtensions.cs

    此方法调用 fails at line 255-ish - 本质上是因为 Mono 默认不信任任何 SSL 证书:as explained here.

    我没有为 Mono 找出正确的配置,而是采取了令人讨厌的路线(至少目前是这样);在我的AppHostBase.Configure 实现中使用以下行:

    F#

    System.Net.ServicePointManager.ServerCertificateValidationCallback <- new RemoteCertificateValidationCallback(fun _ _ _ _ -> true)
    

    C#

    System.Net.ServicePointManager.ServerCertificateValidationCallback += (a, b, c, d) => { return true; };
    

    我现在已经启动并运行(就像一个完全运作的死星)。

    【讨论】:

      猜你喜欢
      • 2013-01-13
      • 2013-04-22
      • 1970-01-01
      • 2014-07-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-06-29
      • 2018-02-24
      相关资源
      最近更新 更多